Mapinfo地图转换成GoogleEarth地图的方法(可编辑修改word版)

合集下载

mapbasic学习之-将mapinfo图导入googleearth图源代码

mapbasic学习之-将mapinfo图导入googleearth图源代码

' Mapinfo2Google.mb ver 1.2.1 8th August, 2005' Copyright ?2005 by Cy Carter' Sydney, Australia'' Mapinfo2Google converts MapInfo layers in a map window to a Google Earth KML file.' Supports point, line, polyline, region, rectangle and text object types.' ARC and ELLIPSE (circle) objects are not supported and are skipped' Object style information extracted but not currently used. Use Google Earth client instead. '' Inspired by Eric Frost's (Oct 2000) MapInfoSVGConverter.mb' and Bill Thoen's MI2SVG.mb' See for Google Earth documentation'' This program is free software; you can redistribute it and/or modify' it under the terms of the GNU General Public License as published by' the Free Software Foundation; either version 2 of the License, or' (at your option) any later version.'' This program is distributed in the hope that it will be useful,' but WITHOUT ANY WARRANTY; without even the implied warranty of' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' GNU General Public License for more details.'' You should have received a copy of the GNU General Public License' along with this program; if not, write to the Free Software Foundation,'-----------------------------------------------------------------------------------------Include "MapBasic.Def"Declare Sub MainDeclare Sub MnuHelpDeclare Sub MnuAboutDeclare Sub MnuExitDeclare Sub SetMsgWinDeclare Sub MnuKML_ConvertMapDeclare Sub KML_ConvertMap (ByVal nMap As Integer, ByVal sOutputFile As String)Dim sErrorMsg As StringSub MainCreate Menu "&Mapinfo2Google" As"&Convert map window to KML file..." Calling MnuKML_ConvertMap,"(-","&Help" Calling MnuHelp,"&About Mapinfo2Google..." Calling MnuAbout,"E&xit Mapinfo2Google" Calling MnuExitAlter Menu Bar Add "&Mapinfo2Google"End Sub'-------------------- Menu Routines -------------------------------------Sub MnuAboutNote "Mapinfo to Google Earth Map Converter" & Chr$(10) & Chr$(10)& "Mapinfo2Google.mbx" & Chr$(10)& "Version 1.2.1 (8th August, 2005)" & Chr$(10)& "Copyright ?2005 by Cy Carter" & Chr$(10)& "This is free software distributed under the terms of the GNU General" & Chr$(10) & "Public License. See /licenses/licenses.html"End Subsub MnuHelpNote "HELP for program Mapinfo2Google " & Chr$(10) & Chr$(10)& "Exports all visible layers except Rasters, Cosmetic or Thematic " & Chr$(10)& "from the current map window to a Goggle Earth KML file." & Chr$(10) & Chr$(10) & "Use Labels of a BASE table to assign a name to each object if required." & Chr$(10) & "Only objects with centroid within the map window are exported." & Chr$(10) End SubSub MnuExitEnd ProgramEnd Sub'-----------------------------------------------------------'Ensure the message window is visible'-----------------------------------------------------------Sub SetMsgWinDim X,Y As FloatDim Xm, Ym As FloatDim Wm, Hm As FloatSet Paper Units "in"X = WindowInfo(WIN_MAPINFO, WIN_INFO_WIDTH) - 3Y = WindowInfo(WIN_MAPINFO, WIN_INFO_HEIGHT) - 3Xm = WindowInfo(WIN_MESSAGE, WIN_INFO_X)Ym = WindowInfo(WIN_MESSAGE, WIN_INFO_Y)Wm = WindowInfo(WIN_MESSAGE, WIN_INFO_WIDTH)Hm = WindowInfo(WIN_MESSAGE, WIN_INFO_HEIGHT)If NOT (WindowInfo(WIN_MESSAGE, WIN_INFO_OPEN)) thenXm = XYm = YWm = 2.5Hm = 2.5End If' fix window if required else leave it as user set itSet Window MessagePosition (Minimum(Xm,X), Minimum(Ym,Y))Width Maximum(2.5, Wm)Height Maximum(2.5, Hm)End Sub'------------------------------------------------------------' Perform reality checks, get user parameters and convert the' map window into an KML file.'------------------------------------------------------------Sub MnuKML_ConvertMapDim sKMLfile As StringDim nWin As IntegerDim StartTime As Integer'Get a map window idIf NumWindows() = 0 ThenNote "You must have a map window open."Exit SubEnd IfnWin = FrontWindow()If WindowInfo (nWin, WIN_INFO_TYPE) <> WIN_MAPPER ThenNote "The top window must be a map."Exit SubEnd If'Window must not be maximized or have scrollbars' If WindowInfo (nWin, WIN_INFO_STATE) <> WIN_STATE_NORMAL Then ' Note "Map window must not be minimised or maximised."' Exit Sub' End If'Nor can the map window have scrollbars on' If MapperInfo (nWin, MAPPER_INFO_SCROLLBARS) Then' Note "Scrollbars must be turned off."' Exit Sub' End If''Get the KLM output filename from the usersKMLfile = FileSaveAsDlg ( ApplicationDirectory$(),"mapinfo2Google", ".kml", "Output file name:")If sKMLfile = "" ThenExit SubEnd If'open message window'StartTime = Timer()print Chr$(12)Print "mapinfo layers to Google KML:"'Convert the map window to KML file.Call KML_ConvertMap (nWin, sKMLfile)If sErrorMsg <> "" ThenPrint sErrorMsgPrint "Program aborted!"ElsePrint PathToFileName$( sKMLfile ) +" is exported!"' Print "Finished! (" + STR$(Timer() - StartTime + 1) + " secs)"End IfEnd Sub'-------------------- Definitions ----------------------------'KML public functionsDeclare Sub KML_WriteHeader (ByVal h As Integer, ByVal fMinX As Float, ByVal fMinY As Float, ByVal fMapWidth As Float, ByVal fMapHeight As Float)Declare Sub KML_ConvertLayer (ByVal nMap As Integer, ByVal nLayer As Integer, ByVal h As Integer)Declare Sub KML_ConvertPoint (ByVal h As Integer, ByVal objPoint As Object, ByVal nId As Integer, ByVal sStyle As String)Declare Sub KML_ConvertLine (ByVal h As Integer, ByVal objLine As Object, ByVal nId As Integer, ByVal sStyle As String)Declare Sub KML_ConvertPline (ByVal h As Integer, ByVal objPline As Object, ByVal nId As Integer, ByVal sStyle As String)Declare Sub KML_ConvertRegion (ByVal h As Integer, ByVal objRegion As Object, ByVal nId AsInteger, ByVal sStyle As String)Declare Sub KML_ConvertText (ByVal h As Integer, ByVal objText As Object, ByVal nId As Integer, ByVal sStyle As String)Declare Sub KML_ConvertRect (ByVal h As Integer, ByVal objFeature As Object, ByVal nId As Integer, ByVal sStyle As String)'Private definitionsDefine SCREEN_DPI_RESOLUTION 96Define XRANGE 90000 ' used for LookAt range calcDefine YRANGE 130000Define STY_POINTS 1Define STY_LINES 2Define STY_POLYGONS 3Define STY_TEXT 4'KML private functionsDeclare Sub KML_GetWinSize (ByVal nMap As Integer, nWidth As Integer, nHeight As Integer) Declare Sub KML_GetMapLimits (ByVal nMap As Integer, fMinX As Float, fMinY As Float, fMaxX As Float, fMaxY As Float)Declare Sub KML_WriteFeatureVectors (ByVal h As Integer, ByVal objFeature As Object, ByVal nId As Integer, ByVal sStyle As String)Declare Function KML_GetGlobalStyles (ByVal nMap As Integer, ByVal nLayer As Integer, sStyles(4) As String) As LogicalDeclare Function KML_GetRegionStyle (ByVal brushStyle As Brush, ByVal penStyle As Pen) As StringDeclare Function KML_GetPenStyle (ByVal penStyle As Pen) As StringDeclare Function KML_GetSymStyle (ByVal symStyle As Symbol) As StringDeclare Function KML_GetTextStyle (ByVal fontText As Font) As StringDeclare Function KML_Color (ByVal nColor As Integer) As String'Module-scope globalsDim m_sFormat As String 'pattern for formatting coordinatesDim m_fPixelWidth As Float 'width of one pixel in map unitsDim goSelRegion As Object 'map window region'----------------------------------------------------------------------'Creates an KML file of map features in visible layers of a map window.'----------------------------------------------------------------------Sub KML_ConvertMap (ByVal nMap As Integer, 'Map window idByVal sOutputFile As String) 'KML output fileDim h As Integer 'file handle for output text fileDim nWidth, nHeight As IntegerDim fMaxX, fMaxY, fMinX, fMinY As FloatDim fMapWidth, fMapHeight As FloatDim i, j As IntegerDIm sOldCoordSys As String' sOldCoordSys = MapperInfo (nMap, MAPPER_INFO_COORDSYS_CLAUSE)'' Set Map Window nMap CoordSys Earth Projection 1, 104 ' set map to Lat/Long WGS 84'' Set CoordSys Earth Projection 1, 104 ' set Mapbasic calcs to same'' Print MapperInfo (nMap, MAPPER_INFO_COORDSYS_NAME)'' If MapperInfo (nMap, MAPPER_INFO_COORDSYS_CLAUSE) = "CoordSys Earth Projection 1, 104" Then'' m_sFormat = "0.######"'' Else'' Print "Try turning off RASTER layers!"'' sErrorMsg = "FATAL ERROR: Map not in LAT/LONG (WGS 84)"'' Note sErrorMsg'' Exit Sub'' End If'Get the window size in pixels. Assume screen resolution of 96 dpi.)Call KML_GetWinSize (nMap, nWidth, nHeight)'Determine the map limitsCall KML_GetMapLimits (nMap, fMinX, fMinY, fMaxX, fMaxY)fMapWidth = fMaxX - fMinXfMapHeight = fMaxY - fMinYm_fPixelWidth = fMapWidth/nWidth'Open the output KML fileh = 1Open File sOutputFile For Output As #h'Write the KML headerCall KML_WriteHeader (h, fMinX, fMaxY, fMapWidth, fMapHeight)'Get the total number of layersj = MapperInfo (nMap, MAPPER_INFO_LAYERS)'Convert map features in the layers. Step from lowest to highest'so that they will be displayed in the right order.For i = j To 1 Step -1If (LayerInfo (nMap, i, LAYER_INFO_DISPLAY) <> LAYER_INFO_DISPLAY_OFF)AND (LayerInfo (nMap, i, LAYER_INFO_TYPE) = LAYER_INFO_TYPE_NORMAL) Then'Convert the layer features to KMLCall KML_ConvertLayer (nMap, i, h)End IfNext'Write the KML end tag and close the filePrint #h, "</Document>"Print #h, "</kml>"Close File #h' Set Map Window nMap sOldCoordSysEnd Sub'-----------------------------------'Determine the window size in pixels'-----------------------------------Sub KML_GetWinSize (ByVal nWin As Integer, 'Map window idnWidth As Integer, 'Returned window width in pixelsnHeight As Integer) 'Returned window height in pixelsDim nResolution As Integer'Set the screen resolutionnResolution = SCREEN_DPI_RESOLUTIONSet Paper Units "in"'Get the window dimensions in pixelsnWidth = Int(WindowInfo(nWin, WIN_INFO_WIDTH) * nResolution)nHeight = Int(WindowInfo(nWin, WIN_INFO_HEIGHT) * nResolution)End Sub'--------------------------------------------------------------'Return the window limits in terms of map units.'--------------------------------------------------------------Sub KML_GetMapLimits (ByVal nMap As Integer, 'Map window idfMinX As Float, 'Returned min X of map windowfMinY As Float, 'Returned min Y of map windowfMaxX As Float, 'Returned max X of map windowfMaxY As Float) 'Returned max Y of map window'Get the map limitsfMaxX = MapperInfo(nMap, MAPPER_INFO_MAXX)fMaxY = MapperInfo(nMap, MAPPER_INFO_MAXY)fMinX = MapperInfo(nMap, MAPPER_INFO_MINX)fMinY = MapperInfo(nMap, MAPPER_INFO_MINY)' Make temporary selection objectCreate Region Into Variable goSelRegion1 4 (fMaxX,fMaxY) (fMaxX,fMinY) (fMinX,fMinY) (fMinX,fMaxY)End Sub'--------------------------'Writes the KML file header'--------------------------Sub KML_WriteHeader (ByVal h As Integer, 'Output KML file handleByVal fMinX As Float, 'X-coord of W edge of mapByVal fMaxY As Float, 'Y-coord of S edge of mapByVal fMapWidth As Float, 'Map width in map unitsByVal fMapHeight As Float) 'Map height in map unitsPrint #h, "<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes""?>" Print #h, "<kml xmlns=""/kml/2.0"">"Print #h, "<Document>"Print #h, "<name>Mapinfo Import</name>"Print #h, " <Style id=""polystyle"">"Print #h, " <LineStyle>"Print #h, " <color>ff7faaff</color>"Print #h, " </LineStyle>"Print #h, " <PolyStyle>"Print #h, " <fill>0</fill>"Print #h, " </PolyStyle>"Print #h, " </Style>"Print #h, " <Style id=""textstyle"">"Print #h, " <IconStyle>"Print #h, " <Icon></Icon>"Print #h, " </IconStyle>"Print #h, " <LabelStyle>"Print #h, " <color>ff0000ff</color>"Print #h, " </LabelStyle>"Print #h, " </Style>"End Sub'----------------------------------------------------------------'Write all the map features to the KML file. This supports only a 'limited selection of MapInfo features and styles.'----------------------------------------------------------------Sub KML_ConvertLayer (ByVal nMap As Integer, 'Map window idByVal nLayer As Integer, 'Layer idByVal h As Integer) 'Output KML file handleDim sStyles(4) As StringDim bStyleOvr As LogicalDim sLayer As StringDim aRow, aObj As AliasDim objA As ObjectDim i, j As IntegerDim nObjType As IntegerDim sStyle As StringDim sName As StringDim nRow As IntegerDim bLables As LogicalDim bMoreLbls As LogicalDim nObj As IntegerDim nObjSkip As IntegerDim bLblOn As Logical'Check for style override and get the default object styles bStyleOvr = KML_GetGlobalStyles (nMap, nLayer, sStyles)'Get layer Table namesLayer = LayerInfo (nMap, nLayer, LAYER_INFO_NAME)'Use the Message window to inform the user of our progress Print "Layer:" + sLayerIf NOT TableInfo(sLayer,TAB_INFO_MAPPABLE) ThenPrint " Skipped - not mappable"Exit SubEnd IfbLblOn = FALSEIf LabelFindFirst(nMap, nLayer, TRUE) ThenIf TableInfo(sLayer, TAB_INFO_TYPE) = TAB_TYPE_BASE thenPrint " Using Label for Object name"bLblOn = TRUESet Map Window nMapLayer nLayer Label Visibility On Auto On Overlap On Duplicates OnUpdate Window nMapElse' PARTIAL WORKAROUND - mapbasic LabelFindByID function does not work correctly on QUERY tables' a possible solution is to iterate the QUERY labels then FETCH the object from the BASE tablePrint " Not a BASE table: Labels were ignored"End IfEnd If'Initialize alias variablesaObj = sLayer + ".obj"aRow = sLayer + ".rowid"'Start an KML folder to contain the layer featuresPrint #h, "<Folder>"Print #h, "<name>Layer " & sLayer & "</name>"nObj = 0nObjSkip = 0'Convert each feature in the layerFetch First From sLayerDo While Not EOT(sLayer)nRow = aRow ' read rowid from layer TABLEobjA = aObj ' get map object from layer TABLEsStyle = ""OnError GoTo No_ObjectnObjType = ObjectInfo (objA, OBJ_INFO_TYPE)OnError GoTo 0if nObjType > 0 thenif objA Within goSelRegion then'--------------------'object inside window'--------------------sName = ""If bLblOn Thenif LabelFindByID(nMap, nLayer, nRow, "", TRUE) thensName = ObjectInfo(LabelInfo(nMap, nLayer, LABEL_INFO_OBJECT),OBJ_INFO_TEXTSTRING)end ifend if'----------------------' Convert object to KML'----------------------Do Case nObjTypeCase OBJ_TYPE_ARCnObjSkip = nObjSkip + 1'-------------------------Case OBJ_TYPE_ELLIPSEnObjSkip = nObjSkip + 1'-------------------------Case OBJ_TYPE_LINECall KML_ConvertLine (h, objA, nRow, sName)'-------------------------Case OBJ_TYPE_PLINECall KML_ConvertPline (h, objA, nRow, sName)'-------------------------Case OBJ_TYPE_POINTCall KML_ConvertPoint (h, objA, nRow, sName)'-------------------------Case OBJ_TYPE_REGIONCall KML_ConvertRegion (h, objA, nRow, sName)'-------------------------Case OBJ_TYPE_RECTCall KML_ConvertRect (h, objA, nRow, sName)'-------------------------Case OBJ_TYPE_ROUNDRECTCall KML_ConvertRect (h, objA, nRow, sName)'-------------------------Case OBJ_TYPE_TEXTCall KML_ConvertText (h, objA, nRow, sStyle)'-------------------------End CasenObj = nObj + 1End IfEnd IfFetch Next From sLayer 'now get next objectLoop'---- end of layer ----------If nObjSkip > 0 thenPrint " Objects Skipped = " + STR$(nObjSkip) + " (ARC or CIRCLE)" End IfPrint " Objects Converted = " + STR$(nObj - nObjSkip)Print #h, "</Folder>"Exit SubNo_Object:nObjtype = 0Resume NextEnd Sub'---------------------------------------------------------------------'Converts a MapInfo point object to KML.'---------------------------------------------------------------------Sub KML_ConvertPoint (ByVal h As Integer, 'Output KML file handleByVal objPoint As Object, 'MI point objectByVal nId As Integer, 'Row IdByVal sName As String) 'LabelDim fx, fy As FloatDim symPoint As Symbolfx = ObjectGeography (objPoint, OBJ_GEO_POINTX)fy = ObjectGeography (objPoint, OBJ_GEO_POINTY)' If sStyle = "" Then' symPoint = ObjectInfo (objPoint, OBJ_INFO_SYMBOL)' sStyle = KML_GetSymStyle (symPoint)' End IfIf sName = "" thensName = "Point " + Str$(nId)End IfPrint #h, "<Placemark>"Print #h, " <name>"Print #h, " <![CDATA[" + Left$(sName,50) + "]]>"Print #h, " </name>"Print #h, " <LookAt>"Print #h, " <longitude>" & Format$(fx, m_sFormat) & "</longitude>"Print #h, " <latitude>" & Format$(fy, m_sFormat) & "</latitude>"Print #h, " <range>1000</range>"Print #h, " <tilt>0</tilt>"Print #h, " <heading>0</heading>"Print #h, " </LookAt>"Print #h, " <Point>"Print #h, " <coordinates>" & Format$(fx, m_sFormat)& "," & Format$(fy, m_sFormat)& ",0</coordinates>"Print #h, " </Point>"Print #h, "</Placemark>"End Sub'---------------------------------------'Converts a MapInfo line object to KML'---------------------------------------Sub KML_ConvertLine (ByVal h As Integer, 'Output KML file handleByVal objLine As Object, 'MI line objectByVal nId As Integer, 'Row IdByVal sName As String) 'LabelDim penLine As PenDim fx, fy As FloatDIM fxe, fye As FloatDim sStr As StringDim nRnge As IntegerDim sStyle As StringIf sStyle = "" ThenpenLine = ObjectInfo (objLine, OBJ_INFO_PEN)sStyle = KML_GetPenStyle (penLine)End Iffx = ObjectGeography (objLine, OBJ_GEO_LINEBEGX)fy = ObjectGeography (objLine, OBJ_GEO_LINEBEGY)fxe = ObjectGeography (objLine, OBJ_GEO_LINEENDX)fye = ObjectGeography (objLine, OBJ_GEO_LINEENDY)nRnge = Int(Maximum(Abs(fx-fxe)*XRANGE,Abs(fy-fye)*YRANGE))If sName = "" thensName = "Line " + Str$(nId)End IfPrint #h, "<Placemark>"Print #h, " <name>"Print #h, " <![CDATA[" + Left$(sName,50) + "]]>"Print #h, " </name>"Print #h, " <LookAt>"Print #h, " <longitude>" & Format$((fx+fxe)/2, m_sFormat) & "</longitude>" Print #h, " <latitude>" & Format$((fy+fye)/2, m_sFormat) & "</latitude>" Print #h, " <range>" & Str$(nRnge) & "</range>"Print #h, " <tilt>0</tilt>"Print #h, " <heading>0</heading>"Print #h, " </LookAt>"Print #h, " <LineString>"Print #h, " <coordinates>"Print #h, " " + Format$(fx, m_sFormat) & "," & Format$(fy, m_sFormat) & ",0" Print #h, " " + Format$(fxe, m_sFormat)& "," & Format$(fye, m_sFormat)& ",0" Print #h, " </coordinates>"Print #h, " </LineString>"Print #h, "</Placemark>"End Sub'---------------------------------------'Writes MI polyline objects to KML file.'---------------------------------------Sub KML_ConvertPline (ByVal h As Integer, 'Output KML file handleByVal objPline As Object, 'MI polyline objectByVal nId As Integer, 'Row IdByVal sName As String) 'LabelDim penPline As PenDim sStyle As StringIf sStyle = "" ThenpenPline = ObjectInfo (objPline, OBJ_INFO_PEN)sStyle = KML_GetPenStyle (penPline)End IfIf sName = "" thensName = "Polyline " + Str$(nId)End IfCall KML_WriteFeatureVectors (h, objPline, nId, sName)End Sub'------------------------------------'Outputs a MapInfo region as KML'------------------------------------Sub KML_ConvertRegion (ByVal h As Integer, 'Output KML file handle ByVal objRegion As Object, 'MI region objectByVal nId As Integer, 'Row IdByVal sName As String) 'Label' Dim penRegion As Pen' Dim brushRegion As Brush'' If sStyle = "" Then' 'Get style from object' penRegion = ObjectInfo (objRegion, OBJ_INFO_PEN)' brushRegion = ObjectInfo (objRegion, OBJ_INFO_BRUSH) ' sStyle = KML_GetRegionStyle (brushRegion, penRegion) ' End IfIf sName = "" thensName = "Region " + Str$(nId)End IfCall KML_WriteFeatureVectors (h, objRegion, nId, sName) End Sub'---------------------------------'Writes MI text object to KML file'---------------------------------Sub KML_ConvertText (ByVal h As Integer, 'Output KML file handleByVal objText As Object, 'MI text objectByVal nId As Integer, 'Row IdByVal sStyle As String) 'KML styleDim fx, fy As FloatDim sText As StringDim fSize As Float' Dim fontText As Font' If sStyle = "" Then' fontText = ObjectInfo (objText, OBJ_INFO_TEXTFONT)' sStyle = KML_GetTextStyle (fontText)' End Iffx = ObjectGeography (objText, OBJ_GEO_MINX)fy = ObjectGeography (objText, OBJ_GEO_MINY)sText = ObjectInfo (objText, OBJ_INFO_TEXTSTRING)fSize = ObjectGeography (objText, OBJ_GEO_MAXY) - ObjectGeography (objText, OBJ_GEO_MINY)Print #h, "<Placemark>"Print #h, " <name>"Print #h, " <![CDATA[" + Left$(sText,50) + "]]>"Print #h, " </name>"Print #h, " <LookAt>"Print #h, " <longitude>" & Format$(fx, m_sFormat) & "</longitude>"Print #h, " <latitude>" & Format$(fy, m_sFormat) & "</latitude>"Print #h, " <range>1000</range>"Print #h, " <tilt>0</tilt>"Print #h, " <heading>0</heading>"Print #h, " </LookAt>"Print #h, " <styleUrl>#textstyle</styleUrl>"Print #h, " <Point>"Print #h, " <coordinates>" & Format$(fx, m_sFormat)& "," & Format$(fy, m_sFormat)& ",0</coordinates>"Print #h, " </Point>"Print #h, "</Placemark>"End Sub'----------------------------------------------'Writes RECT and ROUNDEDRECT to KML file.'----------------------------------------------Sub KML_ConvertRect (ByVal h As Integer, 'Output KML file handleByVal objFeature As Object, 'Rect objectByVal nId As Integer, 'Row IdByVal sName As String) 'LabelDim fx, fy, fx0, fy0, fx1, fy1 As FloatDim nRnge As Integerfx0 = ObjectGeography (objFeature, OBJ_GEO_MINX)fy0 = ObjectGeography (objFeature, OBJ_GEO_MINY)fx1 = ObjectGeography (objFeature, OBJ_GEO_MAXX)fy1 = ObjectGeography (objFeature, OBJ_GEO_MAXY)nRnge = Int(Maximum(Abs(fx0-fx1)* XRANGE, Abs(fy0-fy1)* YRANGE))If sName = "" thensName = "Rect " + Str$(nId)End IfPrint #h, "<Placemark>"Print #h, " <name>"Print #h, " <![CDATA[" + Left$(sName,50) + "]]>"Print #h, " </name>"Print #h, " <LookAt>"Print #h, " <longitude>" & Format$((fx0+fx1)/2, m_sFormat) & "</longitude>" Print #h, " <latitude>" & Format$((fy0+fy1)/2, m_sFormat) & "</latitude>" Print #h, " <range>" & Str$(nRnge) & "</range>"Print #h, " <tilt>0</tilt>"Print #h, " <heading>0</heading>"Print #h, " </LookAt>"Print #h, " <styleUrl>#polystyle</styleUrl>"Print #h, "<Polygon>"Print #h, " <outerBoundaryIs>"Print #h, " <LinearRing>"Print #h, " <coordinates>"Print #h, " " + Format$(fx0, m_sFormat)& "," & Format$(fy0, m_sFormat)& ",0" Print #h, " " + Format$(fx1, m_sFormat)& "," & Format$(fy0, m_sFormat)& ",0" Print #h, " " + Format$(fx1, m_sFormat)& "," & Format$(fy1, m_sFormat)& ",0" Print #h, " " + Format$(fx0, m_sFormat)& "," & Format$(fy1, m_sFormat)& ",0" Print #h, " " + Format$(fx0, m_sFormat)& "," & Format$(fy0, m_sFormat)& ",0" Print #h, " </coordinates>"Print #h, " </LinearRing>"Print #h, " </outerBoundaryIs>"Print #h, "</Polygon>"Print #h, "</Placemark>"End Sub。

基站信息导入Google earth(包括扇区信息)

基站信息导入Google earth(包括扇区信息)

基站扇区导入Google Earth目录1.1软件准备 (3)1.2插件安装 (3)2.1制作基站信息地图 (4)2.2制作基站天线角度信息 (10)3.1导入至Google earth (13)1.1软件准备电脑上必须安装MapInfo、Google Earth软件、SiteSee.mbx和Mapinfo2Google.mbx插件如图1所示图11.2插件安装1.将Mapinfo2Google.mbx和sitesee.mbx复制到MapInfo的安装目录Tools文件夹下2.运行MapInfo软件,添加Mapinfo3Google插件图23.同理安装SiteSee插件安装完成后如上所示。

2.1制作基站信息地图1、打开基站信息Exel文件。

2、选择如下操作。

3、选择数据类型。

4、完成后出现下表,证明导入成功。

5、创建基站图标。

6、设置基站图标7、查看基站位置分布。

8、添加基站信息备注9、完成效果图。

(本图标识了基站名和信道号,有特殊需要请自行设置参数)2.2 转换文件导入到Google earth1、运行MapInfo2Google插件。

2、选择文件存储路径2.2制作基站天线角度信息1、打开含有基站天线角度信息的Exel文件。

将数值类型改成如下图所示。

2、运行sitesee插件3、设置站点信息。

4、保存为MapInfo文件5、出现效果图后,运行MapInfo2Google插件导出为Google earth文件。

3.1导入至Google earth打开Google earth,文件-打开,选择刚生成的*.xml文件,就可在地图上查看标注出的基站了。

效果图如下。

谢谢!。

MapInfo到GoogleEarth的通道(GELink工具)

MapInfo到GoogleEarth的通道(GELink工具)

MapInfo到GoogleEarth的通道(GELink工具)MapInfo到 Google Earth的通道Google这个后起之秀是越来越火了,自从Google推出了Earth 之后,很多人都开始“玩儿转地球”了。

很多GIS软件公司发现后院起火之后非但没有打算救火,而是希望借着这个火“开灶做饭”,于是都推出了有关Google Earth的工具,有的是应用结合,有的是数据交换。

MapInfo在去年就推出了他的工具:GELink,名字很有他的风格,跟ArcLink 差不多。

功能实际上也是差不多的。

主要是将MapInfo的数据转换成Google Earth能打开的kml,同时把属性数据也转换过去,对于其他的比如专题地图,可以通过覆盖栅格图的方式输出到Google Earth中。

当然,对于没有闲钱购买plus或者professional的人来说,绘制线和面确实是一个诱人的月亮,使用GELink可以让你有机会摘到它。

好了,现在告诉你你从哪里能够获得GELink/doc/0d9787260.html,/smartupdate/h tml/pro8.0.cfm在这个页面中有链接可以下载到这个工具,下载后是一个扩展名为EXE的自解压的压缩文件,解压后包含四个文件的安装包。

点击setup.exe进行安装,默认是将程序安装到MapInfo Professional所在目录的tools子目录中。

这个工具是一个使用MapBasic编写的工具,虽然是使用MapBasic7.8编译的,但需要在Professional 8.0上运行,所以你要使用这个工具就必须有MapInfo Professional 8.0。

在MapInfo Professional的工具菜单->运行MapBasic程序菜单项打开对话框,可以在上面所说的目录中找到GELink.mbx这个文件,选中单击确定按钮以运行这个程序。

运行之后,我们会发现在地图菜单的最下方出现一个新的菜单项,从这个菜单项中可以看到三个子菜单项。

mapinfo图转geomap图的操作流程

mapinfo图转geomap图的操作流程

m a p i n f o图转g e o m a p图的操作流程原mapinfo图件是由各个图层组成的,每个图层又由tab、id、map、mid格式组成。

在将该mapinfo图件转换为geomap图件之前,要将其在mapinfo软件中将其转换为mif格式。

1、打开mapinfo软件,单击“文件”菜单下的-“打开”,打开目标mapinfo图件的某一图层的*.tab文件。

2、在mapinfo中打开该图层后,单击“表格”菜单下的“输出”,输出当前图层,生成*.mif 文件。

3、依次操作,直至所有图层都转换为mif格式。

4、打开geomap图形转换工具,单击其“数据”菜单下的“mapinfo数据导入”,选择目标mif文件,然后单击“打开”,即可将该图层导入到图形转换工具中。

然后单击“文件”菜单下的“另存为”,指定保存位置,即可将转换所得的geomap图件存放到指定的位置。

5、依次操作,直至所有mif格式的图层都转换为geomap格式。

6、将该mapinfo图件中任一geomap图层,导入到图册中,做为图件。

将该图件打开,然后在图层处右键单击,选择导入图层,将其它各层导入到当前图件中,然后按坐标叠合,即可将所有图层合并为同一图件中。

Mapinfo图件发现问题分析与处理在对mapinfo图件做图形转换为geomap图件后发现,一旦将图层接坐标叠合,总是有图层上图元消息。

经查看其坐标发现,不同图层所在图幅范围不一致。

最后发现,该问题出现在mapinfo的tab文件中。

例如9-2储层含油饱和度(19)图件,里面的井位和井位边框图层为用户坐标图件,而等值线和等高值等图层为经纬度坐标。

从而另存出的mif文件的坐标信息就是不一致的。

解决方法:1、将图件在mapinfo中打开,然后单击“文件”菜单下的“另存为”,然后选择需要另存的图层,然后单击“另存为(save as、、)”按钮。

2、在弹出的窗口中选择另存文件位置,单击投影(projection)按钮,在弹出的投影类型窗口中选择与井位边框一致的投影类型,然后单击“ok”:输入XY最大、最小值。

网优Mapinfo&GoogleEarth图层制作文档-by Jayjiang

网优Mapinfo&GoogleEarth图层制作文档-by Jayjiang

Mapinfo、Google Earth图层制作版权所有侵权必究修订记录目录1Mapinfo创建站点 (1)1.1主要内容 (1)1.2操作步骤 (1)2基站扇区图层制作 (5)2.1主要内容 (5)2.2制作方法 (6)3Google Earth (10)4图层制作 (10)3.1主要内容 (10)3.2制作方法 (10)5后记 (13)1Mapinfo创建站点1.1主要内容利用mapinfo软件创建站点,在图层上显示站点名。

1.2操作步骤1)将已知的工参表进行整理,新建EXCEL表,数据整理如下图:2)新建一空白文本文档如“长沙站点图层”,将上表的数据全部复制到文本文档中3)打开mapinfo软件,在文件菜单中打开新建的文本文档:如下图:4)打开新建的文本文档后,会提示让你选择文件字符集等信息,如下图:5)点击确定,如下图:6)在菜单栏“表”里选择“创建点”7)创建点时可以根据个人喜好修改符号样式:8)在弹出的7540:OPS对话框中点击“继续”9)右键“图层控制”勾上黄色列:10)点击确定,显示出基站站点分布图及站点名,打开长沙图层后,整体效果如下图:2基站扇区图层制作2.1主要内容利用MapInfo插件sitesee制作基站扇区图层。

2.2制作方法在制作图层过程中,我们所需数据为工程参数,所以对数据的前期准备,此文档不介绍。

1)打开Mapinfo插件Seesite2)点击菜单中的“see site”再点击下级菜单中的“制作基站扇形数据”:3)打开已按格式制作好的工参表,注意:工参为95~03版本的EXCEL文件,基站表的EXCEL数据必须在与SeeSite.mbx同个目录的文件夹“\TAB”中:如:工具 SeeSite.mbx 目录:D:\Mapinfo\SeeSite.MBX 表 RFcon.xls 目录:D:\Mapinfo\TAB\RFcon.xls附:工参表格式样本以及Seesite插件程序。

MapGIS地图应用系列之玩转Google地图

MapGIS地图应用系列之玩转Google地图

MapGIS地图应用系列(二)--玩转Google地图随着数据共享、服务共享在GIS行业势头越来越热,各大地图供应商相继推出在线地图服务,而行业应用的开发者也更倾向于以google、雅虎、百度、必应等地图作为地图,在线调用,结合自己的行业应用,以达到用户体验和功能实用性的双丰收,本篇文章旨在介绍怎样在MapGIS的web开发中使用第三方的在线地图服务,以google 为例。

要在WebGIS开发中使用google地图,首先需要获取google在线地图服务的地址(可以借助火狐浏览器的firebug或者IE9浏览器),其地址获取方式如下(以火狐浏览器为例):方法(一):(1)安装firebug,并启用firebug组件,此时会在地址栏旁边生成一个小甲虫图标,打开火狐浏览器,打开任意地方的google地图浏览(例如武汉),点击小甲虫图标,并启用地图搜索功能搜索武汉,此时会在下方显示一系列http请求的地址,如图所示:(2)将鼠标停靠在地址上,会显示256*256的网格中的一张图片,根据图片判读,找到自己想要显示的区域的,右键--复制地址,可以将地址复制到浏览器地址栏,回车浏览下,检查是不是自己想要的区域,如下图所示:(3)例如,获取到的包括了大部分武汉区域的地址(这里地图类型是普通的矢量瓦片地图类型,也可以是其他类型)为/vt/lyrs=m@189000000,highlight:0x342ea8915476d8a1:0xa6 da2c1d87d542ca@1|style:maps&hl=zh-CN&gl=CN&src=app&x=837&y=420&z= 10&s=Gal,此时,就可以在我们的Flex应用程序中显示武汉地区的google基本地图了,具体做法为代码如下:<?xml version="1.0" encoding="utf-8"?><s:Application xmlns:fx="/mxml/2009"xmlns:s="library:///flex/spark"xmlns:mx="library:///flex/mx" minWidth="955"minHeight="600"xmlns:map="zdims.map.*" xmlns:othermap="zdims.othermap.*"><s:layout><s:BasicLayout/></s:layout><fx:Script><![CDATA[import zdims.othermap.GoogleLayerType;]]></fx:Script><fx:Declarations><!-- 将非可视元素(例如服务、值对象)放在此处--></fx:Declarations><map:IMSMap id="mapContainer" x="192" y="132" width="506" height="234" levelNum="15"xMinMap="-20037508.3427892" xMaxMap=" 20037508.3427892" yMinMap="-20037508.3427892" yMaxMap="20037508.3427892" ><othermap:GoogleTileLayer id="google" x="163" y="77" googleLayerType="{GoogleLayerType.BasicMap}"originalRow="420" originalColumn="837" startLevel="10" ></othermap:GoogleTileLayer></map:IMSMap></s:Application>参数说明如下:红色部分是google所使用的投影坐标系下,对应于经纬度(-180,180)(-90,90)的换算范围,是固定值,无论显示那个区域的地图,这个值不需要变。

Mapinfo2Google操作说明

Mapinfo2Google操作说明

Mapinfo2Google操作说明Mapinfo2Google主要功能是把MAPINFO软件里的图层转换成GOOGLE能打开的KML文件格式。

包括点,线条,区域都可以。

需要先在电脑上安装GOOGLE EARTH软件与Mapinfo2Google插件。

插件如下:一、插件管理其实要把工具加载到MAPINFO里,选择“工具”里面的“工具管理器”,如下图所示:在弹出的“工具管理器”窗口里选择“增加工具”按钮,再在弹出的“增加工具”窗口里分别填写好‘标题’,选择好插件放置的‘位置’后。

按“确定”按钮即可。

如下图所示:按完“确定”按钮后,工具就加载进去了,加载后要记得在“工具管理器”窗口里刚才加载的工具后面“已装入”与“自动装入”框内打勾。

下次打开Mapinfo后就会自动把这个工具加载进去。

再按“确定”键,应该能在菜单栏能看到多了一个“Mapinfo2Google”和选项。

即代表加载插件成功。

其它MAPINFO插件的加载也是用同样的方法来操作。

二、插件使用在MAPINFO里有一个事先画好的区域图层需要转换成GOOGLE文件(即KML格式),如下图红色区域所示。

下面以此为例来说明一下操作步骤:1、先关闭所有图层,然后再打开需要转换的图层(说明:之所以需要先关闭再打开,是因为用这个工具转换的时候窗口不能最大化,打开是什么样子就是什么样子,不要做任何操作,直接在Mapinfo2Google菜单下选第一个转换为KML的选项即可)。

打开后的效果如下图所示:2、打开需要转换的图层后,不要做其它操作,直接选择菜单栏里”Mapinfo2Google”下的”Convert map window to KML file…”即可。

如下图所示:4、点击保存按键后,MAPINFO右下角会有一个消息窗口提示转换完成。

如下图所示:5、可以在保存的路径下找到对应的文件,扩展名是.KML。

如下图所示:6、如果电脑上已经安装好了GOOGLE EARTH软件,直接双击该文件即可打开。

MapInfo数据与Google Earth数据转换

MapInfo数据与Google Earth数据转换

MapInfo数据与Google Earth数据转换
任山君;王琪;杨少敏
【期刊名称】《大地测量与地球动力学》
【年(卷),期】2010(030)B11
【摘要】分析了GIS数据格式与KML数据格式的差异性和数据转换的技术瓶颈,提出了解决方案和总体设计方法。

并以GIS中最常用的Maplnfo数据格式为例,利用MapBasic语言在Maplnfo平台上进行二次开发,编写一个数据转换插件,基本实现了MapInfo到KML格式的数据转换。

【总页数】3页(P75-77)
【作者】任山君;王琪;杨少敏
【作者单位】中国地震局地震研究所,武汉430071
【正文语种】中文
【中图分类】P208
【相关文献】
1.基于Google Earth及Mapinfo数据转换获取蓄水工程水面面积方法的研究 [J], 王超;秦向南;张丽;赵茹
2.MapInfo数据在Google Earth表达的初步研究 [J], 段金荣;刘凯;徐东坡;张敏莹;施炜纲
3.应用GISOffice和Coord将平面直角坐标系数据转换并输出为可导入GoogleEarth的Kml文件 [J], 丁沛
4.MapInfo数据与Google Earth数据转换 [J], 任山君;王琪;杨少敏
5.运用Google Earth和MapInfo建立县级血吸虫病防治地理信息数据库 [J], 张标; 周云; 洪青标; 孙乐平
因版权原因,仅展示原文概要,查看原文内容请购买。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Mapinfo 地图转换成Google Earth 地图的方法
Mapinfo 地图只有平面信息,而Google Earth 中可以看到基站周边的立体信息,方便我们查看基站周边环境,特别是在欧洲,Google Earth 提供的地图精度比较高,在优化中经常用到。

下面就介绍一下利用特定的插件工具生成站点扇区图,并将该Mapinfo 地图转换成Google Earth 地图的方法:
1准备工作
1.1 安装mapinfo 软件并加载插件
在将Mapinfo 地图转换成Google Earth 地图前,我们需要加载两个mapinfo 插件:
1)Mapinfo2Google.MBX:用于Mapinfo 图转换成Google Earth 图
2)SiteSee.MBX:用于画站点三叶图和创建标注图层
3) 安装英文版 mapinfo软件
这两个插件的加载方法是一样的,下面以加载SiteSee.MBX 为例,如下:
1)Tool menu Tool Manager
2)Add Tool
3)选择插件的路径,建议先将要导入的插件先拷贝到Mapinfo 安装目前中的Tool 文件夹下
4)选择启动Mapinfo 时自动加载插件
5)插件加载后SiteSee.MBX 出现在Table Menu 中,Mapinfo2Google.MBX 出现在主菜单上,如下:
1.2 准备Mapinfo 地图
做mapinfo 图层的方法有多种,下面介绍一下SiteSee.MBX 插件创建mapinfo 图层的方法:
1.2.1准备一个包含小区信息的EXCEL 文件(或文本文件)
1)在Mapinfo 中打开这个EXCEL 文件,转换成Mapinfo 表:
2)如果M apinfo打不开E XCEL文件,可将EXCEL 文件保存为“制表符分隔”的文本文件。

在Mapinfo 中打开文
本文件,“File Character Set”选择“No character set conversion”,点击“OK” 转换成Mapinfo 表:
1.2.2使用SiteSee.MBX 工具画三叶图
画出的三叶图如下所示:
2生成Google Earth 图层
2.1 创建三叶图图层
1)在mapinfo 中打开需要转换成Google Earth 地图的图层,并为图层加上标注
2)Google2mapinfo.MBX工具有一个特殊要求:需要转换的图层不能最大化显示,所以要将需要转换的图层调整成下
面的窗口大小;
3)鼠标右键点击需要转换的图层,在弹出菜单中选择“View Entire layer”(插件只将窗口内显示的站点转换为.kml
文件,因此需要显示整个图层)
4)在Mapinfo2Google 菜单中选择“convert map window to KML file”
5)在Google Earth 软件中打开生成的文件即可
2.2 创建标注图层
1)使用SiteSee.MBX 插件中的Create sector label 功能,生成一个标注图层
2)在mapinfo 的map 菜单中选择“save cosmetic objects”,保存生成的标注图层,关闭所有地图窗口只打开生成的
标注图层窗口,与生成三叶图图层一样,把标注图层窗口非最大化显示,然后选择“View Entire layer”,之后就可以开始转换了。

3)标注图层如果是汉字,导入Google Earth 后显示为乱码。

解决办法是将生成的.KML 文件用“记事本打开”,
单击“另存为”,保存时将“编码”项改为“Unicode”(事实上编码只要不选择“ANSI”都可以)。

保存后再导入Google Earth,乱码问题就解决了。

在Google Earth 中显示的结果如下图所示:
附件:
Mapinfo2Google.MB
SiteSee.MBX
X。

相关文档
最新文档