1 / 53

MapXtreme 高级教程 ————利用 MapXtreme 构建企业级的 WebGIS

MapXtreme 高级教程 ————利用 MapXtreme 构建企业级的 WebGIS. 版权所有: Mapinfo China 技术部 邹德禹 2001 年 2 月. 主要内容. ◆ 基于 MapXtreme 的 WebGIS 开发 ◆ WebGIS 开发案例分析. 基于 MapXtreme 的 WebGIS 体系结构. 在构建 MapXtreme 应用之前,应考虑的一个问题. 在构建 MapXtreme 应用之前,应当事先考虑到网站的扩展问题。 对于大访问量的网站,可以有两种扩展方式来支持多用户访问。

zizi
Download Presentation

MapXtreme 高级教程 ————利用 MapXtreme 构建企业级的 WebGIS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MapXtreme 高级教程 ————利用MapXtreme构建企业级的WebGIS 版权所有:Mapinfo China 技术部 邹德禹 2001年2月

  2. 主要内容 ◆基于MapXtreme的WebGIS开发 ◆WebGIS开发案例分析

  3. 基于MapXtreme的WebGIS体系结构

  4. 在构建MapXtreme应用之前,应考虑的一个问题 • 在构建MapXtreme应用之前,应当事先考虑到网站的扩展问题。 • 对于大访问量的网站,可以有两种扩展方式来支持多用户访问。 • Vertical Scalability: 这种扩展方式,主要是通过增加单个服务器的物理性能,如增加内存,CPU等来实现的。在构建 这种类型的网站时,会用到MapXBroker对象。 • Horizontal Scalability:这种扩展方式,是通过增加服务器来分担单台服务器的过重负载的。这时,需要在每台服务上安装MapXtreme. • 一般采用Vertical Scalability方式。 • Horizontal Scalability方式的成本很高。 • 培训中的所有示例都适用于以Vertical Scalability方式构建的应用。

  5. RDBMS RDBMS RDBMS WebGIS的三种架构 Medium Thin Fat Internet GIF Image GIF & Java Applet MapJ & Vectors Map Xtreme Map Xtreme Map Xtreme

  6. MapXtreme的系统的连网工作方式

  7. 地图可以存放 在RDBMS上 关系数据库 Internet 文件服务器(TAB) Web服务器 利用MapXtrem构建的三层系统结构

  8. 构建MapXtreme分布式服务体系结构 • 支持分布式服务体系结构是MapXtreme的一个重要的特性。MapXtreme支持分布式结构的重要因素在于它的良好的开放性。因为它能与任何标准的Web Server相连,MapXtreme与WebServer的连接是通过应用服务器完成的,如Microsoft的ASP,或者国外流行的Haht hahtsite(MapXtreme自带Haht hahtsite开发环境,用户无须另外单独购买网络应用开发工具)。一个Web Server可以任意挂接多个 MapXtreme地图应用服务器。MapXtreme的Server可以自动维护和协调WebServer和多个MapXtreme之间的请求响应关系。无须用户编程解决。

  9. 基于MapXtreme的WebGIS应用开发

  10. 开 发 环 境 Web 服务器 • Internet Development(e.g. HAHT site,Microsoft InterDev • Sample Applications • MapXtreme Server • Tools • Map Data • Application Server Publish Application Via file copy or FTP MapXtreme应用的开发方式 • MapXtreme提供了Development Tools Development Tools包括MapXtreme Sample Applications及MapXtreme Code Libs,它们可以从光盘上直接安装。 开发方式 程序员可以使用自己的机器开发,等应用完成后,再通过文件copy或是FTP将文件传送到服务器上的WEB站点主目录所对应的物理路径下。 如果是采用Visual interDev开发环境的话,则此开发环境还支持远程程序调试,则只需要在一台服务器上安装MapXtreme,程序员便可以在多台机器上同时进行开发。 程序员也可以直接在服务器上进行开发。

  11. 软件开发环境 •  Microsoft ASP(InterDev) • 在ASP(Active Server Page)方式下,MapXtreme在 • Server端的开发语言为VBScript或者JavaScript。开发环 • 境为Visual InterDev。MapXtreme还向用户提供了Java Applet的源码,便于用户添加和维护自己的应用。 •  Hahtsite 集成开发环境 • 其它集成开发环境

  12. MapXtreme与MapX的关系 • MapXtreme的技术核心是MapX, 针对MapX产品的编程 • 知识和经验都可以适用于MapXtreme应用的开发。 • MapXtreme可以实现MapX的全部功能 • MapXtreme本身又是一个Server,它能在多用户 • 访问时自动进行平衡负载,协调MapX的工作 • 用户不需要进行任何多用户访问平衡负载的编程工作, • 这一切由MapXtreme的Server和Application Server自动完成

  13. 如何写一个最简单的MapXtreme ASP程序 • 1. 建立一个存放页面文件的目录C:\maptest\Hello Tute • 2. 在IIS管理器中为C:\maptest\Hello Tute 创建一个虚拟目录 “/hellotute” ,并确保使该虚拟目录可执行ASP脚本程序。 • 3.在IIS管理器中创建一个名叫 “mapimage”的虚拟目录,使用指向 “C:\temp”。 • 4. 将MapXtreme 代码库拷贝到 C:\maptest\lib下。 • 5.利用记事本创建一个名叫default.htm的文件。内容如下: • <HTML> • <BODY> • <P>MapXtreme 'Hello Wrold' Tutorial</P> • <P><A href="mappage.asp">View World Map</A></P> • </BODY> • </HTML> • 6.利用记事本创建一个名叫global.asa的文件。内容如下: • <!--#include file = "..\lib\miConst.asp">--> • <script language = "vbscript" runat = "Server"> • sub session_onstart • set session(SESN_MAPPER) = nothing • set session(SESN_COURIER) = nothing • end sub • </script>

  14. 如何写一个最简单的MapXtreme ASP程序(接上页) • 6.利用记事本创建一个名叫mappage.asp的文件。内容如下: • <%@ LANGUAGE = VBScript %> • <!--#INCLUDE FILE="..\lib\miConst.asp"--> • <!--#INCLUDE FILE="..\lib\miMapEngine.asp"--> • <!--#INCLUDE FILE="..\lib\miUtilities.asp"--> • <% Dim bResult • Dim strFile • Dim strMapPath • Dim strMapVirtual • bResult = InitMapEngine(OBTAIN_DIRECTLY,Session(SESN_MAPNAME)) • SetMapGeoset("World.gst") • SetMapTitleText("Hello Tutorial") • strFile = CreateUniqueFileName() • strFile = strFile & ".gif" • strMapPath = "c:\temp\" & strFile • strMapVirtual = "/mapimage/" & strFile • bResult = ExportMapToGIF(strMapPath) %> • <HTML> • <HEAD><TITLE>Hello Tutorial</TITLE></HEAD> • <BODY><IMG SRC="<% = strMapPath %>"></BODY> • </HTML>

  15. 如何写一个最简单的MapXtreme ASP程序(接上页) • 7.在浏览器中键入http://george/hellotute便可运行此程序。 • 程序说明: • default.htm:它是应用的缺省主页。 • Global.asa:该文件中定义了两用来访问MapX对象的对象变量 • mappage.asp:它是整个应用的核心文件,在该文件中生成了一个MapX对象的实例,并为生成的位图指定了存放路径,以及将生成的位图显示到页面上。 • 当在浏览器中键入http://george/hellotute时IE会自动请求访问该页面。这个页面上有一个链接,它指向mappage.asp页。 • 当用户点击缺省主页面上的链接时,IE便会请求访问mappaga.asp页面。这时服务器便会启动一个用户Session,并先于mappage.asp页面之前,先执行global.asa文件。 • 执行完global.asa文件后,执行mappage.asp文件。 • 8.几个主要函数的功能及使用说明 InitMapEngine(intMethod,strName):此函数用来初始化一个MapX实例。 intMethod:有两个可选参数,OBTAIN_DIRECTLY 或 OBTAIN_FROM_BROKER如果每个MapXCourier都直接启动一个MapX实例,则使用OBTAIN_DIRECTLY,如果MapXCourier通过MapXBroker来获取MapX实例,则使用OBTAIN_FROM_BROKER。 strName:如果intMethod使用OBTAIN_DIRECTLY,则strName表示一个GeoSet名, 如果intMethod使用OBTAIN_FROM_BROKER则strName表示一个MapXBroker组名。

  16. 如何写一个最简单的MapXtreme ASP程序(接上页) • SetMapGeoset • 设置使用的GST地图 • SetMapTitleText • 设置显示在WEB页面上的地图标题 • ExportMapToGIF • 将地图处理结果生成位图

  17. 如果对上述程序的功能进行增强 • 例如:如何在页面上增加几个按钮,实现地图的放大,缩小,漫游。 • 见示例程序。 • 如何理解这个程序: • 对于同一个用户会话,如果MapX实例已经存在,则不应再创建新的对象实例。 • 需要将用户在屏幕上点击的坐标,转换成经纬度坐标。 • 需要利用HTML标鉴在页面上加几个地图操作按钮。 • 为了让服务器能知道,用户进行了何种地图操作,必须在页面上使用Form表单,来提交用户的地图操作请求。 • 必须将用户的地图操作请求(放大,缩小等),传递到服务器上,让MapX实例进行相应的操作。 • 每次都用同一个mappage.asp文件显示地图处理结果,所以mappage.asp上的Form表单的Action都必须指向同一个mappage.asp。

  18. Hello World 实例分析:

  19. MapPage.asp Application.asp Global.asa Debugpage.asp miErrorSystem.asp miMapEngine.asp MapXtreme 进阶ASP Code Library Hello World References the code library contained in MapXtreme 2.0 for Windows NT

  20. Hello World 实例分析: Global.asa 用户会话中止 如果客户端在几分钟内没有操作,则这个用户的会话过程会自动操作中止. Session_OnEnd Call Courier.DeleteFiles(删除文件) Call Courier.ReleaseMapX 释放MapX对象 当会话超时后, IIS 会自动清除会话所包含的各种参数变量

  21. Session_OnStart Global.asa Default.htm Hello World 实例分析: From Default.htm, user clicks link to MapPage.asp 初始化系统变量 例如: Session(SESN_ABSMAPPATH):临时GIF 文件的路径 Session(SESN_TOOL):当前的工具操作状态(放大、缩小、平移?) Session(SESN_WIDTH), Session(SESN_HEIGHT):地图的宽度和高度 Session(SESN_MAPNAME) = “World Countries”调入的地图名字 Session.Timeout = 3 会话超时时间

  22. Hello World 实例分析: InitErrorSystem() InitMapEngine() CreateUniqueFilename() ExportMapToFile() miUtilities.asp miMapEngine.asp “主程序入口” Mappage.asp 首先要调用 SetupMappingEngine() Application.asp miErrorSystem.asp miMapEngine.asp 如果初始化地图引擎失败, MapPage.asp 调用“busy.asp”; 否则继续

  23. CommandHandler Application.asp AdjustMap Application.asp DeleteFiles miUtilities.asp ExportMapToFile miMapEngine.asp Hello World 实例分析: 每次用户在客户端发生操作,如地图放大 “main” MapPage.asp ConvertScreenCoordsToMap miMapEngine.asp SetMapCenterAndZoomTo miMapEngine.asp

  24. Hello World 实例分析: CommandHandler Application.asp ZoomMap Application.asp SetMapZoom miMapEngine.asp DeleteFiles() ExportMapToFile() miUtilities.asp miMapEngine.asp 用户端操作改变地图视野大小 “main” Mappage.asp

  25. Hello World 实例分析 RebuildMap SetupMappingEngine 如果SetupMappingEngine 探测到这个用户是上一次会话超时 (which timed out), 则调用RebuildMap: Application.asp Application.asp 变量重新初始化 Global.asa “main” Mappage.asp 当上一个会话超时之后,用户又点击地图 If the user’s session has timed out, and then the user clicks the map to zoom in, the request creates an all new session on the server. RebuildMap读取 hidden form fields中的 数值恢复上一次超实时的地图状态.

  26. Hello World 实例分析 AdjustMap Application.asp ExportMapToFile() miMapEngine.asp 当RebuildMap 恢复好上一次地图状态 (zoom level, center x, center y) 之后, 再进行放大、缩小、中心显示等操作。 这样用户感不到上一次操作已经超时 CommandHandler Application.asp SetMapCenterAndZoomTo miMapEngine.asp

  27. MapX 的核心功能

  28. 如何获取MapX对象? Function InitMapEngine(ByVal intMethod, ByVal strName) Dim bResult On Error Resume Next If intMethod = OBTAIN_DIRECTLY Then Set Session(SESN_MAPPER) = Session(SESN_COURIER).GetMapXFromNewServer(strName) Else Set Session(SESN_MAPPER) = Session(SESN_COURIER).GetMapXFromBroker(strName, 15000) End If End Function 此函数等价于 Set Session( "MAP" ) = Server.CreateObject( "MapX.Map.3" )

  29. MapInfo terminology MapInfo Professional’sMapObject = MapX’s Feature

  30. Features Collection • A Feature is an item on a map layer. It can be of type line, region, text or symbol. • A collection of Feature objects, created by methods of the features object: AllFeatures, NoFeatures, SearchAtPoint, SearchWithinDistance, SearchWithinRectangle, SearchWithinFeature • Each layer object may have multiple features collections

  31. SearchAtPoint • Returns a features collection of the features at a given point from a particular layer.

  32. PrintMapTools() • Prints the tools (form field inputs) that allow the user to zoom in, zoom out, pan, etc. • Must give the user the ability to activate this tool through PrintMapTools(), the functionality of the tool is handled in CommandHandler routine

  33. CommandHandler • Determines what tool (if any) was just used on the map and takes the appropriate actions on the map

  34. Adding New Tools • Need to do two things: • Add tools to the PrintMapTools (or another equivalent) routine • Process the tool’s use in CommandHandler (or another equivalent) procedure

  35. Plotting Points • Datasets Overview [MapX] • ODBC Datasets [MapX] • BindLayer [MapX] • ODBC Datasets [Haht]

  36. DataBinding • A way of tying data from an external source to the map • Creates a DATASET when data is bound to a MapX map layer • Why? • Theme maps • Query information • Summarization of data geographically • Create a new layer of points

  37. Three Types of Databinding • Normal • Bind data to existing map features • XY Bind [Requires use of BindLayer object] • Creates symbols on the fly from long/lat coordinates already in your database • PointRef [Requires use of BindLayer object] • Creates symbols on the fly by matching geographic information in your database against features on an existing map layer

  38. Normal Data Binding

  39. “Normal” Data Binding • Datasource Fields aggregated and attached to an existing map layer • You can specify Key Field and/or Layer • OR • MapX can determine Key Field and/or Layer

  40. Data Binding using BindLayer Object

  41. X-Y Data Binding • Datasource already contains X & Y coordinates • You specify X,Y and Key Fields via BindLayer object • New point layer is created • Remaining datasource fields are bound to the new layer as a dataset

  42. Point Reference Binding • Datasource contains geographic key such as zipcode • You specify key Field and Reference layer via BindLayer object • New point layer is created with a point for each row in the datasource • Remaining datasource fields are bound to the new layer as a dataset

  43. BindLayer Object • Used as a parameter to the Datasets.add method • Specifies how to create new symbols from your data • Must be able to geo-reference data • Needs Longitude and Latitude OR • A field that can be matched up against a map layer (zipcode, city, district, etc)

  44. MapXtreme进阶——如何进行系统调试 1、必须安装IIS 3.0 、 ASP、ServerPack3、 OptionPack4 2、安装BackOffice中的FrontPage Extension Server 3、安装InterDev6.0

  45. 如何增强客户端的交互性 两种方案: 1、客户端采取Java Applet插件 2、客户端采取ActiveX插件

  46. 两种技术方案的比较

  47. 成功案例…

  48. 电子商务

  49. 企业智能业务

More Related