📄 geoevent.frm
字号:
Dim pPoint As IPoint
Set pPoint = pElement.Geometry
'Create new random point coordinates based upon current location
pPoint.x = pPoint.x - (dMaxDistance * (Rnd - 0.5))
pPoint.y = pPoint.y - (dMaxDistance * (Rnd - 0.5))
'Set the point onto the GeographicCoordinateSystem - WHERE the point came FROM
pPoint.Project m_pGeographicCoordinateSystem
'Ensure that the point is within the horizon of the coordinate system. Mollweide
'has a generic rectangular horizon withe the following limits:
'-179.999988540844, -90.000000000000, 179.999988540844, 90.000000000000
If pPoint.x > 179.999988540844 Then
pPoint.x = pPoint.x - 359.999977081688
ElseIf pPoint.x < -179.999988540844 Then
pPoint.x = pPoint.x + 359.999977081688
End If
If pPoint.y > 89.891975 Then 'fudge value to clip near poles
pPoint.y = pPoint.y - 179.78395
ElseIf pPoint.y < -89.891975 Then 'fudge value to clip near poles
pPoint.y = pPoint.y + 179.78395
End If
'Project the point onto the displays current spatial reference
'WHERE the point is going TO
pPoint.Project m_pProjectedCoordinateSystem
pElement.Geometry = pPoint
End If
Set pElement = m_pGraphicsContainer.Next
Loop
'Refresh the graphics
MapControl1.Refresh esriViewGraphics
End Sub
Private Sub DisplayAgentLocation(agent As AGENT_IN_FIELD)
'Create a point and get the IPoint interface
Dim pPoint As IPoint
Set pPoint = New Point
'Set the points x and y coordinates
pPoint.PutCoords agent.Longitude, agent.Latitude
'Set the points spatial reference - WHERE the point is coming FROM
Set pPoint.SpatialReference = m_pGeographicCoordinateSystem
'Project the point onto the displays current spatial reference - WHERE the point is going TO
pPoint.Project m_pProjectedCoordinateSystem
'Create a marker element and get the IElement interface
Dim pElement As IElement
Set pElement = New MarkerElement
'Set the elements geometry
pElement.Geometry = pPoint
'QI for the IMarkerElement interface from the IElement interface
Dim pMarkerElement As IMarkerElement
Set pMarkerElement = pElement
'Set the marker symbol
pMarkerElement.Symbol = GetMarkerSymbol(agent.Located)
'QI for the IElementProperties interface from the IMarkerElement interface
Dim pElementProperties As IElementProperties
Set pElementProperties = pMarkerElement
pElementProperties.Name = agent.Located
'Add the element to the graphics container
m_pGraphicsContainer.AddElement pElement, 0
End Sub
Private Function GetMarkerSymbol(bLocated As Boolean)
'Create a new font
Dim pFont As New stdole.StdFont
pFont.Name = "ESRI Crime Analysis"
'Create a new CharacterMarkerSymbol and get the ICharacterMarkerSymbol interface
Dim pCharMarker As ICharacterMarkerSymbol
Set pCharMarker = New CharacterMarkerSymbol
'Set the marker symbol properties
pCharMarker.Font = pFont
If bLocated = True Then
pCharMarker.CharacterIndex = 56
pCharMarker.Color = GetRGBColor(255, 0, 0)
pCharMarker.Size = 30
Else
pCharMarker.CharacterIndex = 46
pCharMarker.Color = GetRGBColor(0, 0, 0)
pCharMarker.Size = 30
End If
Set GetMarkerSymbol = pCharMarker
End Function
Private Sub MakeCoordinateSystems()
'Create a spatial reference environment and get theISpatialReferenceFactory2 interface
Dim pSpatRefFact As ISpatialReferenceFactory2
Set pSpatRefFact = New SpatialReferenceEnvironment
'Create a geographic coordinate system and get the IGeographicCoordinateSystem interface
Set m_pGeographicCoordinateSystem = pSpatRefFact.CreateGeographicCoordinateSystem(esriSRGeoCS_WGS1984)
'Create a projected coordinate system and get the IProjectedCoordinateSystem interface
Set m_pProjectedCoordinateSystem = pSpatRefFact.CreateProjectedCoordinateSystem(esriSRProjCS_World_Mollweide)
'Set the map controls spatial reference property
Set MapControl1.SpatialReference = m_pProjectedCoordinateSystem
End Sub
Private Sub SymbolizeData(pLayer As ILayer2, dWidth As Double, pColorLine As IRgbColor, pColorFill As IRgbColor)
'Create a line symbol and get the ILineSymbol interface
Dim pLineSymbol As ILineSymbol
Set pLineSymbol = New SimpleLineSymbol
'Set the line symbol properties
pLineSymbol.Width = dWidth
pLineSymbol.Color = pColorLine
'Create a fill symbol and get the IFillSymbol interface
Dim pFillSymbol As ISimpleFillSymbol
Set pFillSymbol = New SimpleFillSymbol
'Set the fill symbol properties
pFillSymbol.Outline = pLineSymbol
pFillSymbol.Color = pColorFill
'Create a simple renderer and get the ISimpleRenderer interface
Dim pSimpleRenderer As ISimpleRenderer
Set pSimpleRenderer = New SimpleRenderer
'Set the simple renderer properties
Set pSimpleRenderer.Symbol = pFillSymbol
'QI for the IGeoFeatureLayer interface from the ILayer2 interface
Dim pGeoFeatureLayer As IGeoFeatureLayer
Set pGeoFeatureLayer = pLayer
'Set the GeoFeatureLayer properties
Set pGeoFeatureLayer.Renderer = pSimpleRenderer
End Sub
Private Function GetRGBColor(pRed As Long, pGreen As Long, pBlue As Long) As IRgbColor
'Create an RGB color and get the IRGBColor interface
Dim pRGB As IRgbColor
Set pRGB = New RgbColor
'Set rgb color properties
With pRGB
.Red = pRed
.Green = pGreen
.Blue = pBlue
End With
Set GetRGBColor = pRGB
End Function
Private Sub LoadAgentArray()
'Populate an array of agent locations and id's. The locations are in decimal degrees,
'based on the WGS1984 geographic coordinate system. (ie unprojected).
'Obviously, these values could be read directly from a GPS unit.
agentArray(0).CodeNumber = "001"
agentArray(0).Latitude = 56.185128983308
agentArray(0).Longitude = 37.556904400607
agentArray(0).Located = False
agentArray(1).CodeNumber = "002"
agentArray(1).Latitude = 48.3732928679818
agentArray(1).Longitude = 6.91047040971168
agentArray(1).Located = False
agentArray(2).CodeNumber = "003"
agentArray(2).Latitude = 32.1487101669196
agentArray(2).Longitude = 39.3596358118361
agentArray(2).Located = False
agentArray(3).CodeNumber = "004"
agentArray(3).Latitude = 29.7450682852807
agentArray(3).Longitude = 71.2078907435508
agentArray(3).Located = False
agentArray(4).CodeNumber = "005"
agentArray(4).Latitude = 38.7587253414264
agentArray(4).Longitude = 138.509863429439
agentArray(4).Located = False
agentArray(5).CodeNumber = "006"
agentArray(5).Latitude = 35.1532625189681
agentArray(5).Longitude = -82.0242792109256
agentArray(5).Located = False
agentArray(6).CodeNumber = "007"
agentArray(6).Latitude = -26.1396054628225
agentArray(6).Longitude = 28.5432473444613
agentArray(6).Located = True
agentArray(7).CodeNumber = "008"
agentArray(7).Latitude = 33.9514415781487
agentArray(7).Longitude = 3.90591805766313
agentArray(7).Located = False
agentArray(8).CodeNumber = "009"
agentArray(8).Latitude = 29.7450682852807
agentArray(8).Longitude = 16.5250379362671
agentArray(8).Located = False
agentArray(9).CodeNumber = "010"
agentArray(9).Latitude = 45.9696509863429
agentArray(9).Longitude = 23.1350531107739
agentArray(9).Located = False
agentArray(10).CodeNumber = "011"
agentArray(10).Latitude = 48.9742033383915
agentArray(10).Longitude = 14.1213960546282
agentArray(10).Located = False
agentArray(11).CodeNumber = "012"
agentArray(11).Latitude = 29.7450682852807
agentArray(11).Longitude = 79.0197268588771
agentArray(11).Located = False
agentArray(12).CodeNumber = "013"
agentArray(12).Latitude = 43.5660091047041
agentArray(12).Longitude = 125.289833080425
agentArray(12).Located = False
agentArray(13).CodeNumber = "014"
agentArray(13).Latitude = 7.5113808801214
agentArray(13).Longitude = -68.2033383915023
agentArray(13).Located = False
agentArray(14).CodeNumber = "015"
agentArray(14).Latitude = 9.31411229135053
agentArray(14).Longitude = -79.6206373292868
agentArray(14).Located = False
agentArray(15).CodeNumber = "016"
agentArray(15).Latitude = 8.71320182094082
agentArray(15).Longitude = -9.31411229135053
agentArray(15).Located = True
agentArray(16).CodeNumber = "017"
agentArray(16).Latitude = 22.5341426403642
agentArray(16).Longitude = 53.7814871016692
agentArray(16).Located = False
agentArray(17).CodeNumber = "018"
agentArray(17).Latitude = 42.3641881638847
agentArray(17).Longitude = 45.9696509863429
agentArray(17).Located = False
agentArray(18).CodeNumber = "019"
agentArray(18).Latitude = 39.3596358118361
agentArray(18).Longitude = 27.9423368740516
agentArray(18).Located = False
agentArray(19).CodeNumber = "020"
agentArray(19).Latitude = 22.5341426403642
agentArray(19).Longitude = 104.257966616085
agentArray(19).Located = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -