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; } }
// 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)); }
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); } }