/** * Constructs a new map layer definition. */ public MapLayer() { grid_valid = false; encode_cell_radius = true; aoi_manual = GeoExtent.invalid(); aoi_auto = GeoExtent.invalid(); }
public void TestExtentExpansion() { /* * Empty extent * + */ GeoExtent extent = new GeoExtent(4740877.11612745, 4740877.11612745, 329020.170629896, 329020.170629896); Assert.IsTrue(extent.IsEmpty); Assert.AreEqual(0.0, extent.Width, 0.001); Assert.AreEqual(0.0, extent.Height, 0.001); /* * Extent expanded with 20km on each side * +-----+ * | + | * +-----+ */ extent.Expand(20000); Assert.IsFalse(extent.IsEmpty); Assert.AreEqual(40000.0, extent.Width, 0.001); Assert.AreEqual(40000.0, extent.Height, 0.001); }
public void BatchTransformWithParameters() { GeoExtent extent = new GeoExtent(4590706, 4556298, 8561889, 8519105); extent.Expand(20000); Transformations tr = new Transformations(); double[] parameters = tr.CalculateAffineTransformationParameters(extent, enumProjection.BGS_1970_K9, enumProjection.BGS_2005_KK); int count = 100000; GeoPoint[] input = new GeoPoint[count]; GeoPoint[] expected = new GeoPoint[count]; for (int i = 0; i < count; i++) { input[i] = new GeoPoint(4573488, 8539465); expected[i] = new GeoPoint(4700322.190, 361795.526); } // check results for (int i = 0; i < count; i++) { GeoPoint result = tr.TransformBGSCoordinates(input[i], parameters, enumProjection.BGS_1970_K9, enumProjection.BGS_2005_KK); Common.CheckResults(expected[i], result, Common.DELTA_BGS_EXTENT); } }
private void recalculateGrid() { num_rows = 0; num_cols = 0; dx = 0.0; last_dx = 0.0; dy = 0.0; last_dy = 0.0; GeoExtent aoi = getAreaOfInterest(); if (aoi.isValid()) { GeoPoint sw = aoi.getSouthwest(); GeoPoint ne = aoi.getNortheast(); SpatialReference srs = aoi.getSRS(); if (getCellHeight() > 0.0) { num_rows = (uint)Math.Ceiling(aoi.getHeight() / getCellHeight()); dy = getCellHeight(); last_dy = aoi.getHeight() % getCellHeight(); if (last_dy == 0.0) { last_dy = dy; } } else { num_rows = 1; dy = last_dy = aoi.getHeight(); } if (getCellWidth() > 0.0) { num_cols = (uint)Math.Ceiling(aoi.getWidth() / getCellWidth()); dx = getCellWidth(); last_dx = aoi.getWidth() % getCellWidth(); if (last_dx == 0.0) { last_dx = dx; } } else { num_cols = 1; dx = last_dx = aoi.getWidth(); } grid_valid = true; } }
/*** Statics ********************************************************/ static bool getTerrainData(Terrain terrain, out osg.Node out_terrain_node, out SpatialReference out_terrain_srs, out GeoExtent out_terrain_extent) { if (terrain != null) { if (!string.IsNullOrEmpty(terrain.getURI())) { out_terrain_node = osgDB.readNodeFile(terrain.getAbsoluteURI()); } // first check for an explicity defined SRS: out_terrain_srs = terrain.getExplicitSRS(); if (out_terrain_srs != null && out_terrain_srs.isGeographic()) { // and make it geocentric if necessary.. out_terrain_srs = Registry.SRSFactory().createGeocentricSRS(out_terrain_srs.get()); } if (out_terrain_node != null) { // if the SRS wasn't explicit, try to read it from the scene graph: if (out_terrain_srs == null) { out_terrain_srs = Registry.SRSFactory().createSRSfromTerrain(out_terrain_node.get()); } //osgGIS.notice() // << "Loaded TERRAIN from \"" << terrain.getAbsoluteURI() << "\", SRS = " // << (out_terrain_srs != null? out_terrain_srs.getName() : "unknown") // << std.endl; } else if (!string.IsNullOrEmpty(terrain.getURI())) { //osgGIS.warn() // << "Unable to load data for terrain \"" // << terrain.getName() << "\"." // << std.endl; return(false); } } out_terrain_extent = new GeoExtent(-180, -90, 180, 90, Registry.instance().getSRSFactory().createWGS84()); return(true); }
// MapLayerCompiler interface public virtual Profile createProfile() { // determine the output SRS: SpatialReference out_srs = map_layer.getOutputSRS(getSession(), terrain_srs); if (out_srs == null) { //osgGIS.warn() << "Unable to figure out the output SRS; aborting." << std.endl; return(null); } // figure out the bounds of the compilation area and create a Q map. We want a sqaure AOI..maybe GeoExtent aoi = map_layer.getAreaOfInterest(); if (aoi == null) { //osgGIS.warn() << "Invalid area of interest in the map layer - no data?" << std.endl; return(null); } QuadMap qmap; if (out_srs.isGeocentric()) { // for a geocentric map, use a modified GEO quadkey: // (yes, that MIN_LAT of -180 is correct...we want a square) qmap = new QuadMap(new GeoExtent(-180.0, -180.0, 180.0, 90.0, Registry.SRSFactory().createWGS84())); } else { double max_span = Math.Max(aoi.getWidth(), aoi.getHeight()); GeoPoint sw = aoi.getSouthwest(); GeoPoint ne = new GeoPoint(sw.x() + max_span, sw.y() + max_span, aoi.getSRS()); qmap = new QuadMap(new GeoExtent(sw, ne)); } #if TODO qmap.setStringStyle(QuadMap.STYLE_LOD_QUADKEY); #endif // osgGIS.notice() // << "QMAP: " << std.endl // << " Top LOD = " << getTopLod( qmap, map_layer.get() ) << std.endl // << " Depth = " << map_layer.getMaxDepth() << std.endl // << " Extent = " << qmap.getBounds().toString() << ", w=" << qmap.getBounds().getWidth() << ", h=" << qmap.getBounds().getHeight() << std.endl // << std.endl; return(new QuadTreeProfile(qmap)); }
/** * Sets the reference terrain against which to compile. */ //public void setTerrain( // osg.Node terrain, // SpatialReference terrain_srs =NULL, // GeoExtent terrain_extent =GeoExtent.infinite() ) public void setTerrain(osg.Node _terrain, SpatialReference _terrain_srs, GeoExtent _terrain_extent) { terrain_node = _terrain; terrain_srs = (SpatialReference)_terrain_srs; terrain_extent = _terrain_extent; if (terrain_srs == null) { terrain_srs = MogreGis.Registry.SRSFactory().createSRSfromTerrain(terrain_node.get()); } //if ( !terrain_srs.valid() ) // osgGIS.warn() << "[MapLayerCompiler] WARNING: cannot determine SRS of terrain!" << std.endl; }
public void TestExtentParameters() { /* * Extent * +-----+ * | | * | | * +-----+ */ GeoExtent extent = new GeoExtent(4748066.96065451, 4740877.11612745, 329020.170629896, 321536.921920285); double width = 7483.249; double height = 7189.845; Assert.IsFalse(extent.IsEmpty); Assert.AreEqual(width, extent.Width, 0.001); Assert.AreEqual(height, extent.Height, 0.001); /* * Extent with empty height * +-----+ */ extent = new GeoExtent(4748066.96065451, 4748066.96065451, 329020.170629896, 321536.921920285); Assert.IsFalse(extent.IsEmpty); Assert.AreEqual(7483.249, extent.Width, 0.001); Assert.AreEqual(0.0, extent.Height, 0.001); /* * Extent with empty width * + * | * | * + */ extent = new GeoExtent(4748066.96065451, 4740877.11612745, 329020.170629896, 329020.170629896); Assert.IsFalse(extent.IsEmpty); Assert.AreEqual(0.0, extent.Width, 0.001); Assert.AreEqual(7189.845, extent.Height, 0.001); /* * Empty extent * + */ extent = new GeoExtent(4740877.11612745, 4740877.11612745, 329020.170629896, 329020.170629896); Assert.IsTrue(extent.IsEmpty); Assert.AreEqual(0.0, extent.Width, 0.001); Assert.AreEqual(0.0, extent.Height, 0.001); }
public void CalculateParametersForExtent() { GeoExtent extent = new GeoExtent(4590706, 4556298, 8561889, 8519105); extent.Expand(20000); Transformations tr = new Transformations(); double[] parameters = tr.CalculateAffineTransformationParameters(extent, enumProjection.BGS_1970_K9, enumProjection.BGS_2005_KK); // K9 GeoPoint input = new GeoPoint(4573488, 8539465); GeoPoint expected = new GeoPoint(4700322.190, 361795.526); GeoPoint result = tr.TransformBGSCoordinates(input, parameters, enumProjection.BGS_1970_K9, enumProjection.BGS_2005_KK); Common.CheckResults(expected, result, Common.DELTA_BGS_EXTENT); input = new GeoPoint(4557529, 8530750); expected = new GeoPoint(4684583.019, 352691.179); result = tr.TransformBGSCoordinates(input, parameters, enumProjection.BGS_1970_K9, enumProjection.BGS_2005_KK); Common.CheckResults(expected, result, Common.DELTA_BGS_EXTENT); input = new GeoPoint(4589108, 8551915); expected = new GeoPoint(4715630.512, 374624.861); result = tr.TransformBGSCoordinates(input, parameters, enumProjection.BGS_1970_K9, enumProjection.BGS_2005_KK); Common.CheckResults(expected, result, Common.DELTA_BGS_EXTENT); input = new GeoPoint(4573488, 8517394); expected = new GeoPoint(4700865.033, 339732.391); result = tr.TransformBGSCoordinates(input, parameters, enumProjection.BGS_1970_K9, enumProjection.BGS_2005_KK); Common.CheckResults(expected, result, Common.DELTA_BGS_EXTENT); input = new GeoPoint(4574394, 8583155); expected = new GeoPoint(4700154.937, 405492.239); result = tr.TransformBGSCoordinates(input, parameters, enumProjection.BGS_1970_K9, enumProjection.BGS_2005_KK); Common.CheckResults(expected, result, Common.DELTA_BGS_EXTENT); }
public GeoExtent TileBounds(int tx, int ty, int zoom) { GeoExtent retval = new GeoExtent(); try { var min = this.PixelsToMeters(tx * this.tileSize, ty * this.tileSize, zoom); var max = this.PixelsToMeters((tx + 1) * this.tileSize, (ty + 1) * this.tileSize, zoom); retval = new GeoExtent() { North = max.Y, South = min.Y, East = max.X, West = min.X }; return(retval); } catch (Exception ex) { throw ex; } }
public GeoExtent TileLatLonBounds(int tx, int ty, int zoom) { GeoExtent retval = new GeoExtent(); try { var bounds = this.TileBounds(tx, ty, zoom); var min = this.MetersToLatLon(bounds.West, bounds.South); var max = this.MetersToLatLon(bounds.East, bounds.North); retval = new GeoExtent() { North = max.Y, South = min.Y, East = max.X, West = min.X }; return(retval); } catch (Exception ex) { throw ex; } }
/** * Gets the cell range that incorporates the AOI at the specified LOD. */ public bool getCells( GeoExtent aoi, uint lod, out uint out_cell_xmin, out uint out_cell_ymin, out uint out_cell_xmax, out uint out_cell_ymax);
public QuadMap(GeoExtent bounds);
/** * Sets the geospatial extent bounding the area we want to build. * * @param extent Geospatial area of interest */ public void setAreaOfInterest(GeoExtent value) { aoi_manual = value; grid_valid = false; }
/// <summary> /// Get a set of control points located inside an extent /// </summary> /// <param name="extent"></param> /// <returns></returns> public List <GeoPoint> GetPoints(GeoExtent extent) { List <Point <GeoPoint> > queried = this.tree.Query(extent.SouthWestCorner.X, extent.SouthWestCorner.Y, extent.NorthEastCorner.X, extent.NorthEastCorner.Y); return(queried.Select(p => p.UserData).OrderBy(p => p.ID).ToList()); }
protected void setCenterAndRadius(osg.Node node, GeoExtent cell_extent, SmartReadCallback reader) { SpatialReference srs = map_layer.getOutputSRS(getSession(), getTerrainSRS()); // first get the output srs centroid: GeoPoint centroid = srs.transform(cell_extent.getCentroid()); GeoPoint sw = srs.transform(cell_extent.getSouthwest()); double radius = map_layer.getEncodeCellRadius() ? (centroid - sw).length() : -1.0; if (terrain_node.valid() && terrain_srs != null) { GeoPoint clamped; for (int t = 0; t < 5; t++) { clamped = GeomUtils.clampToTerrain(centroid, terrain_node.get(), terrain_srs, reader); if (!clamped.isValid()) { // if the clamp failed, it's due to the geocentric intersection bug in which the isect // fails when coplanar with a tile boundary/skirt. Fudge the centroid and try again. double fudge = 0.001 * ((double)(1 + (Random.Rand() % 10))); centroid.X += fudge; centroid.Y -= fudge; centroid.Z += fudge * fudge; } else { break; } } if (!clamped.isValid()) { SpatialReference geo = srs.getGeographicSRS(); GeoPoint latlon = geo.transform(centroid); //osgGIS.warn() << "*** UNABLE TO CLAMP CENTROID: ***" << latlon.toString() << std.endl; } else { centroid = clamped; } } else { //osgGIS.warn() << "*** Failed to clamp Center/Radius for cell" << std.endl; } if (node is osg.LOD) { osg.LOD plod = (osg.LOD)node; plod.setCenter(centroid); plod.setRadius(radius); } else if (node is osg.ProxyNode) { osg.ProxyNode proxy = (osg.ProxyNode)node; proxy.setCenter(centroid); proxy.setRadius(radius); } }