public ShapeFileLayer(string id, World parentWorld, string shapeFilePath, double minimumViewingAltitude, double maximumViewingAltitude, float lztsd, GeographicBoundingBox bounds, string dataKey, bool scaleColorsToData, double scalarFilterMin, double scalarFilterMax, double scaleMin, double scaleMax, string[] noDataValues, string[] activeDataValues, bool polygonFill, bool outlinePolygons, Color polygonFillColor, ShapeFillStyle shapeFillHatchStyle, Color lineColor, float lineWidth, bool showLabels, Color labelColor, string iconFilePath, int iconWidth, int iconHeight, byte iconOpacity) : base(id, parentWorld.Position, parentWorld.Orientation) { m_MinimumViewingAltitude = minimumViewingAltitude; m_MaximumViewingAltitude = maximumViewingAltitude; m_lztsd = lztsd; m_ShapeTileArgs = new ShapeTileArgs(parentWorld, new Size(256, 256), parentWorld.EquatorialRadius, this, dataKey, scaleColorsToData, scaleMin, scaleMax, noDataValues, activeDataValues, polygonFill, outlinePolygons, polygonFillColor, shapeFillHatchStyle, lineColor, labelColor, lineWidth, showLabels); m_ScalarFilterMin = scalarFilterMin; m_ScalarFilterMax = scalarFilterMax; m_ShapeFilePath = shapeFilePath; m_IconFilePath = iconFilePath; m_IconWidth = iconWidth; m_IconHeight = iconHeight; m_IconOpacity = iconOpacity; /*Produces tile tree for whole earth*/ /*Need to implement clipping*/ m_NumberRootTilesHigh = (int) (180.0f/m_lztsd); double tileSize = 180.0f/m_NumberRootTilesHigh; m_RootTiles = new ShapeTile[m_NumberRootTilesHigh*(m_NumberRootTilesHigh*2)]; //System.Console.WriteLine("North:{0} South:{1} East:{2} West:{3}", // bounds.North,bounds.South,bounds.East,bounds.West); int istart = 0; int iend = m_NumberRootTilesHigh; int jstart = 0; int jend = m_NumberRootTilesHigh*2; int createdtiles = 0; for (int i = istart; i < iend; i++) { for (int j = jstart; j < jend; j++) { double north = (i + 1)*tileSize - 90.0f; double south = i*tileSize - 90.0f; double west = j*tileSize - 180.0f; double east = (j + 1)*tileSize - 180.0f; m_RootTiles[i*m_NumberRootTilesHigh*2 + j] = new ShapeTile(new GeographicBoundingBox(north, south, west, east), m_ShapeTileArgs); m_RootTiles[i*m_NumberRootTilesHigh*2 + j].Level = 0; m_RootTiles[i*m_NumberRootTilesHigh*2 + j].Row = i; m_RootTiles[i*m_NumberRootTilesHigh*2 + j].Col = j; createdtiles++; } } //Console.WriteLine("Created Tiles "+createdtiles); }
public void Update(DrawArgs drawArgs) { try { double centerLatitude = 0.5*(m_GeoBB.North + m_GeoBB.South); double centerLongitude = 0.5*(m_GeoBB.West + m_GeoBB.East); double tileSize = m_GeoBB.North - m_GeoBB.South; if (!m_Initialized) { if (drawArgs.WorldCamera.ViewRange*0.5f < Angle.FromDegrees(ShapeTileArgs.TileDrawDistance*tileSize) && MathEngine.SphericalDistance(Angle.FromDegrees(centerLatitude), Angle.FromDegrees(centerLongitude), drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude) < Angle.FromDegrees(ShapeTileArgs.TileSpreadFactor*tileSize*1.25f) && drawArgs.WorldCamera.ViewFrustum.Intersects(BoundingBox)) { Initialize(drawArgs); } } if (m_Initialized) { if (m_NwImageLayer != null) { m_NwImageLayer.Update(drawArgs); } if (m_NeImageLayer != null) { m_NeImageLayer.Update(drawArgs); } if (m_SwImageLayer != null) { m_SwImageLayer.Update(drawArgs); } if (m_SeImageLayer != null) { m_SeImageLayer.Update(drawArgs); } if (drawArgs.WorldCamera.ViewRange < Angle.FromDegrees(ShapeTileArgs.TileDrawDistance*tileSize) && MathEngine.SphericalDistance(Angle.FromDegrees(centerLatitude), Angle.FromDegrees(centerLongitude), drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude) < Angle.FromDegrees(ShapeTileArgs.TileSpreadFactor*tileSize) && drawArgs.WorldCamera.ViewFrustum.Intersects(BoundingBox)) { if (m_NorthEastChild == null && m_NorthWestChild == null && m_SouthEastChild == null && m_SouthWestChild == null) { ComputeChildren(drawArgs); } else { if (m_NorthEastChild != null) { m_NorthEastChild.Update(drawArgs); } if (m_NorthWestChild != null) { m_NorthWestChild.Update(drawArgs); } if (m_SouthEastChild != null) { m_SouthEastChild.Update(drawArgs); } if (m_SouthWestChild != null) { m_SouthWestChild.Update(drawArgs); } } } else { if (m_NorthWestChild != null) { m_NorthWestChild.Dispose(); m_NorthWestChild = null; } if (m_NorthEastChild != null) { m_NorthEastChild.Dispose(); m_NorthEastChild = null; } if (m_SouthEastChild != null) { m_SouthEastChild.Dispose(); m_SouthEastChild = null; } if (m_SouthWestChild != null) { m_SouthWestChild.Dispose(); m_SouthWestChild = null; } } } if (m_Initialized) { if (drawArgs.WorldCamera.ViewRange > Angle.FromDegrees(ShapeTileArgs.TileDrawDistance*tileSize*1.5f) || MathEngine.SphericalDistance(Angle.FromDegrees(centerLatitude), Angle.FromDegrees(centerLongitude), drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude) > Angle.FromDegrees(ShapeTileArgs.TileSpreadFactor*tileSize*1.5f)) { //if(this.level != 0) //{ Dispose(); //} } } } catch (Exception ex) { Log.Write(ex); } }
private ShapeTile ComputeChild(DrawArgs drawArgs, double childSouth, double childNorth, double childWest, double childEast, double tileSize) { ShapeTile child = new ShapeTile(new GeographicBoundingBox(childNorth, childSouth, childWest, childEast), m_ShapeTileArgs); return child; }
public virtual void ComputeChildren(DrawArgs drawArgs) { float tileSize = (float) (0.5*(m_GeoBB.North - m_GeoBB.South)); //TODO: Stop children computation at some lower level if (tileSize > 0.0001) { double CenterLat = 0.5f*(m_GeoBB.North + m_GeoBB.South); double CenterLon = 0.5f*(m_GeoBB.East + m_GeoBB.West); if (m_NorthWestChild == null && m_NwImageLayer != null && m_Initialized) { m_NorthWestChild = ComputeChild(drawArgs, CenterLat, m_GeoBB.North, m_GeoBB.West, CenterLon, tileSize); m_NorthWestChild.Level = Level++; m_NorthWestChild.Row = 2*Row + 1; m_NorthWestChild.Col = 2*Col; m_NorthWestChild.Initialize(drawArgs); } if (m_NorthEastChild == null && m_NeImageLayer != null && m_Initialized) { m_NorthEastChild = ComputeChild(drawArgs, CenterLat, m_GeoBB.North, CenterLon, m_GeoBB.East, tileSize); m_NorthEastChild.Level = Level++; m_NorthEastChild.Row = 2*Row + 1; m_NorthEastChild.Col = 2*Col + 1; m_NorthEastChild.Initialize(drawArgs); } if (m_SouthWestChild == null && m_SwImageLayer != null && m_Initialized) { m_SouthWestChild = ComputeChild(drawArgs, m_GeoBB.South, CenterLat, m_GeoBB.West, CenterLon, tileSize); m_SouthWestChild.Level = Level++; m_SouthWestChild.Row = 2*Row; m_SouthWestChild.Col = 2*Col; m_SouthWestChild.Initialize(drawArgs); } if (m_SouthEastChild == null && m_SeImageLayer != null && m_Initialized) { m_SouthEastChild = ComputeChild(drawArgs, m_GeoBB.South, CenterLat, CenterLon, m_GeoBB.East, tileSize); m_SouthEastChild.Level = Level++; m_SouthEastChild.Row = 2*Row; m_SouthEastChild.Col = 2*Col + 1; m_SouthEastChild.Initialize(drawArgs); } } }