Ejemplo n.º 1
0
 /**
  * Constructs a new map layer definition.
  */
 public MapLayer()
 {
     grid_valid = false;
     encode_cell_radius = true;
     aoi_manual = GeoExtent.invalid();
     aoi_auto = GeoExtent.invalid();
 }
Ejemplo n.º 2
0
        public List <DATA> find(GeoExtent extent)
        {
            List <DATA> list = new List <DATA>();

            find(root_id, extent, list);
            return(list);
        }
Ejemplo n.º 3
0
        /**
         * Returns true if another extent intersects this extent.
         * @param input
         *      Extent to test against this extent.
         */
        public bool intersects(GeoExtent input)
        {
            if (!isValid() || !input.isValid() || isEmpty() || input.isEmpty())
            {
                return(false);
            }

            if (isInfinite() || input.isInfinite())
            {
                return(true);
            }

            GeoPoint input_sw = getSRS().transform(input.getSouthwest());
            GeoPoint input_ne = getSRS().transform(input.getNortheast());

            bool isect;

            if (ne.X < input_sw.X || sw.X > input_ne.X ||
                ne.Y < input_sw.Y || sw.Y > input_ne.Y)
            {
                isect = false;
            }
            else
            {
                isect = true;
            }

            return(isect);
        }
Ejemplo n.º 4
0
        /**
         * Returns true if this extent intersects the minimum bounding rectangle
         * that encompasses a set of points.
         * @param input
         *      Points to test against extent.
         */
        public bool intersectsExtent(GeoPointList input)
        {
            GeoExtent input_extent = new GeoExtent();

            input_extent.expandToInclude(input);
            return(intersects(input_extent));
        }
Ejemplo n.º 5
0
 /**
  * Returns true if an extent falls completely within this extent.
  * @param input
  *      Extent to test for containment.
  */
 public bool contains(GeoExtent input)
 {
     return
         (input.isValid() &&
          contains(input.getSouthwest()) &&
          contains(input.getNortheast()));
 }
Ejemplo n.º 6
0
 /**
  * Sets the spatial bounds that a filter should consider relevant under
  * this environment.
  *
  * @param extent Working spatial extent
  */
 public void setExtent(GeoExtent extent)
 {
     feature_extent = extent;
     if (cell_extent.isInfinite())
     {
         cell_extent = extent;
     }
 }
Ejemplo n.º 7
0
 /**
  * Constructs a new, default filter environment.
  *
  * @param session
  *      Session in which this filter environment exists.
  */
 private FilterEnv(Session _session)
 {
     session        = _session;
     feature_extent = GeoExtent.infinite();
     cell_extent    = GeoExtent.infinite();
     resource_cache = new ResourceCache();
     report         = new Report();
 }
Ejemplo n.º 8
0
        /**
         * Adds a new part to the shape, preallocating space for the points,
         * and returns a reference to it.
         * @param num_points
         *      The number of points to preallocate in the part.
         */
        public GeoPointList addPart(int num_points)
        {
            extent_cache = GeoExtent.invalid();
            GeoPointList list = new GeoPointList(num_points);

            parts.Add(list);
            return(list);
        }
Ejemplo n.º 9
0
 bool visitPoint(GeoPoint p)
 {
     if (e == null && p != null)
     {
         e = new GeoExtent();
     }
     e.expandToInclude(p);
     return(true);
 }
Ejemplo n.º 10
0
 /**
  * Copy constructor.
  */
 public GeoExtent(GeoExtent rhs)
 {
     ne = rhs.ne;
     sw = rhs.sw;
     se = rhs.se;
     nw = rhs.nw;
     is_valid = rhs.is_valid;
     is_infinite = rhs.is_infinite;
     recalc();
 }
Ejemplo n.º 11
0
 /**
  * Copy constructor.
  */
 public GeoExtent(GeoExtent rhs)
 {
     ne          = rhs.ne;
     sw          = rhs.sw;
     se          = rhs.se;
     nw          = rhs.nw;
     is_valid    = rhs.is_valid;
     is_infinite = rhs.is_infinite;
     recalc();
 }
Ejemplo n.º 12
0
 /**
  * Constructs a feature cursor
  *
  * @param oids
  *      Object IDs of features over which to iterate
  * @param store
  *      Feature store from which to read the Feature data
  * @param search_extent
  *      Search extent that was used to generate the list of OIDs in this
  *      cursor - this is used to refine the list of Features actually
  *      returned from the cursor
  * @param match_exactly
  *      True to only return Feature instances that "exactly" match the
  *      original search criteria. When querying a FeatureStore by spatial
  *      extent (GeoExtent), the store will actually return a FeatureCursor
  *      corresponding to all features whose bounding extents intersect the
  *      search extent; i.e. it does not test down to the shape level. Passing
  *      true to this parameter will perform shape-level intersection testing
  *      when using this cursor.
  */
 public FeatureCursor(
     FeatureOIDList _oids,
     FeatureStore _store,
     GeoExtent _search_extent,
     bool _match_exactly)
 {
     oids          = _oids;
     store         = _store;
     search_extent = _search_extent;
     match_exactly = _match_exactly;
     prefetch_size = DEFAULT_PREFETCH_SIZE;
     at_bof        = false;
     reset();
 }
Ejemplo n.º 13
0
 public void insert(GeoExtent extent, DATA data)
 {
     // adjust zero-area extents
     if (extent.getArea() == 0.0)
     {
         GeoExtent extent2 = extent;
         extent2.expand(0.0001, 0.0001);
         insert(root_id, extent2, data);
     }
     else
     {
         insert(root_id, extent, data);
     }
 }
Ejemplo n.º 14
0
 /**
  * Constructs a feature cursor
  *
  * @param oids
  *      Object IDs of features over which to iterate
  * @param store
  *      Feature store from which to read the Feature data
  * @param search_extent
  *      Search extent that was used to generate the list of OIDs in this
  *      cursor - this is used to refine the list of Features actually
  *      returned from the cursor
  * @param match_exactly
  *      True to only return Feature instances that "exactly" match the
  *      original search criteria. When querying a FeatureStore by spatial
  *      extent (GeoExtent), the store will actually return a FeatureCursor
  *      corresponding to all features whose bounding extents intersect the
  *      search extent; i.e. it does not test down to the shape level. Passing
  *      true to this parameter will perform shape-level intersection testing
  *      when using this cursor.
  */
 public FeatureCursor(
     FeatureOIDList _oids,
     FeatureStore _store,
     GeoExtent _search_extent,
     bool _match_exactly)
 {
     oids = _oids;
     store = _store;
     search_extent = _search_extent;
     match_exactly = _match_exactly;
     prefetch_size = DEFAULT_PREFETCH_SIZE;
     at_bof = false;
     reset();
 }
Ejemplo n.º 15
0
        /**
         * Gets the spatial bounds of all the feature data within this layer.
         *
         * @return Extent of the layer
         */
        public GeoExtent getExtent()
        {
            GeoExtent e = store.getExtent();

            if (e.isValid())
            {
                return(e);
            }

            //TODO osgGIS::warn() << "Store " << store->getName() << " did not report an extent; calculating..." << std::endl;

            this.assertSpatialIndex();
            return(index != null ? index.getExtent() : (store != null ? store.getExtent() : GeoExtent.invalid()));
        }
Ejemplo n.º 16
0
 /**
  * Modifies this extent to include another extent.
  * @param extent
  *      Extent to include.
  */
 public void expandToInclude(GeoExtent input)
 {
     if (input.isValid() && !input.isEmpty() && !isInfinite())
     {
         if (input.isInfinite())
         {
             is_infinite = true;
         }
         else
         {
             expandToInclude(input.getSouthwest());
             expandToInclude(input.getNortheast());
         }
     }
 }
Ejemplo n.º 17
0
        public FeatureCursor getCursor(GeoExtent query_extent, bool match_exactly)
        {
            FeatureOIDList oids = new FeatureOIDList();
            for (FeatureCursor cursor = store.getCursor(); cursor.hasNext(); )
            {
                Feature  feature = cursor.next();
                  GeoExtent f_extent = feature.getExtent();
                if (f_extent.intersects(query_extent))
                {
                    oids.Add(feature.getOID());
                }
            }

            return new FeatureCursor(oids, store , query_extent, match_exactly);
        }
Ejemplo n.º 18
0
        public FeatureCursor getCursor(GeoExtent query_extent, bool match_exactly)
        {
            FeatureOIDList oids = new FeatureOIDList();

            for (FeatureCursor cursor = store.getCursor(); cursor.hasNext();)
            {
                Feature   feature  = cursor.next();
                GeoExtent f_extent = feature.getExtent();
                if (f_extent.intersects(query_extent))
                {
                    oids.Add(feature.getOID());
                }
            }

            return(new FeatureCursor(oids, store, query_extent, match_exactly));
        }
Ejemplo n.º 19
0
 /**
  * Visits each point in the shape with a user-provided visitor.
  */
 public bool accept(GeoPointVisitor visitor)
 {
     extent_cache = GeoExtent.invalid();
     for (int pi = 0; pi < getPartCount(); pi++)
     {
         GeoPointList part = getPart(pi);
         for (int vi = 0; vi < part.Count; vi++)
         {
             if (!visitor.visitPoint(part[vi]))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Ejemplo n.º 20
0
        /**
         * Returns an extent representing the intersection two extents.
         * @param input
         *      Extent to intersect with this object.
         * @return
         *      Intersection extent.
         */
        public GeoExtent getIntersection(GeoExtent _rhs)
        {
            GeoExtent rhs = getSRS().transform(_rhs);

            if (rhs.getXMin() >= getXMax() || rhs.getXMax() <= getXMin() ||
                rhs.getYMin() >= getYMax() || rhs.getYMax() <= getYMin())
            {
                return(GeoExtent.empty());
            }

            double xmin = rhs.getXMin() < getXMin() ? getXMin() : rhs.getXMin();
            double xmax = rhs.getXMax() > getXMax() ? getXMax() : rhs.getXMax();
            double ymin = rhs.getYMin() < getYMin() ? getYMin() : rhs.getYMin();
            double ymax = rhs.getYMax() > getYMax() ? getYMax() : rhs.getYMax();

            return(new GeoExtent(xmin, ymin, xmax, ymax, getSRS()));
        }
Ejemplo n.º 21
0
        /**
         * Gets a cursor that will iterate over all the features whose extents
         * intersect the specified extent.
         *
         * @param extent
         *      Spatial area of interest to query
         * @return
         *      A cursor for iterating over search results
         */
        public FeatureCursor getCursor(GeoExtent extent)
        {
            if (extent.isInfinite())
            {
                return(getCursor());
            }
            else
            {
                assertSpatialIndex();
                if (index != null)
                {
                    return(index.getCursor(extent));
                }
            }

            //TODO osgGIS::notify( osg::WARN )
            //   << "osgGIS::FeatureLayer::createCursor, no spatial index available" << std::endl;
            return(new FeatureCursor());
        }
Ejemplo n.º 22
0
 public bool intersects(GeoExtent ex)
 {
     if (ex.isInfinite())
     {
         return(true);
     }
     if (ex.isPoint())
     {
         GeoPoint     point   = ex.sw;
         bool         result  = false;
         GeoPointList polygon = this;
         for (int i = 0, j = polygon.Count - 1; i < polygon.Count; j = i++)
         {
             if ((((polygon[i].Y <= point.Y) && (point.Y < polygon[j].Y)) ||
                  ((polygon[j].Y <= point.Y) && (point.Y < polygon[i].Y))) &&
                 (point.X < (polygon[j].X - polygon[i].X) *
                  (point.Y - polygon[i].Y) / (polygon[j].Y - polygon[i].Y) + polygon[i].X))
             {
                 result = !result;
             }
         }
         return(result);
     }
     else //check for all points within extent -- not actually correct //TODO
     {
         GeoExtent e;
         e = new GeoExtent(this[0], this[0]);
         foreach (GeoPoint geoPoint in this)
         {
             if (geoPoint == this[0])
             {
                 //NOP
             }
             else
             {
                 e.expandToInclude(geoPoint);
             }
         }
         return(e.intersects(ex));
     }
 }
Ejemplo n.º 23
0
 /**
  * Modifies this extent to include another extent.
  * @param extent
  *      Extent to include.
  */
 public void expandToInclude(GeoExtent input)
 {
     if (input.isValid() && !input.isEmpty() && !isInfinite())
     {
         if (input.isInfinite())
         {
             is_infinite = true;
         }
         else
         {
             expandToInclude(input.getSouthwest());
             expandToInclude(input.getNortheast());
         }
     }
 }
Ejemplo n.º 24
0
        //osg::Image* createImage( 
        //    const GeoExtent& extent, 
        //    int max_span_pixels,
        //    bool force_power_of_2_dimensions ) const;

        public Image createImage( GeoExtent extent,
                                  int image_width,
                                  int image_height);
Ejemplo n.º 25
0
        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);
            }
        }
Ejemplo n.º 26
0
 ExtentVisitor()
 {
     e = GeoExtent.invalid();
 }
Ejemplo n.º 27
0
 public osg.HeightField createHeightField(
     GeoExtent aoi);
Ejemplo n.º 28
0
 /**
  * Transforms an extent into this srs.
  *
  * @param input
  *      Extent to transform into this SRS
  * @return
  *      Transformed extent, or GeoExtent::invalid() upon failure
  */
 public abstract GeoExtent transform(GeoExtent input);
Ejemplo n.º 29
0
 /**
  * Constructs a new, empty shape.
  */
 public GeoShape()
 {
     extent_cache = GeoExtent.invalid();
 }
Ejemplo n.º 30
0
 /**
  * Returns true if this extent intersects the minimum bounding rectangle
  * that encompasses a set of points.
  * @param input
  *      Points to test against extent.
  */
 public bool intersectsExtent(GeoPointList input)
 {
     GeoExtent input_extent = new GeoExtent();
     input_extent.expandToInclude(input);
     return intersects(input_extent);
 }
Ejemplo n.º 31
0
 /**
  * Transforms an extent into this srs.
  *
  * @param input
  *      Extent to transform into this SRS
  * @return
  *      Transformed extent, or GeoExtent::invalid() upon failure
  */
 public abstract GeoExtent transform(GeoExtent input);
Ejemplo n.º 32
0
        /**
         * Gets a cursor that will iterate over all the features whose extents
         * intersect the specified extent.
         *
         * @param extent
         *      Spatial area of interest to query
         * @return
         *      A cursor for iterating over search results
         */
        public FeatureCursor getCursor(GeoExtent extent)
        {
            if (extent.isInfinite())
            {
                return getCursor();
            }
            else
            {
                assertSpatialIndex();
                if (index != null)
                {
                    return index.getCursor(extent);
                }
            }

            //TODO osgGIS::notify( osg::WARN )
            //   << "osgGIS::FeatureLayer::createCursor, no spatial index available" << std::endl;
            return new FeatureCursor();
        }
Ejemplo n.º 33
0
 /**
  * Calculates and returns an image size that will best accomodate an osg::Image
  * that spans the provided AOI. Typically you would call this and use the generated
  * size in a call to createImage().
  *
  * @param aoi
  *      Spatial extent of raster area to query
  * @param max_pixel_span
  *      Maximum number of pixels in either dimension
  * @param force_power_of_2
  *      Round the resulting dimensions so that they are powers of 2
  * @param out_image_width
  *      Upon success, stores the calculated width to this variable
  * @param out_image_height
  *      Upon success, stores the calcluates height to this variable.
  *
  * @return
  *      True upon success, False upon failure.
  */
 public abstract bool getOptimalImageSize(GeoExtent aoi,
     uint max_pixel_span,
     bool force_power_of_2,
     out uint out_image_width,
     out uint out_image_height);
Ejemplo n.º 34
0
 /**
  * Extracts an RGBA image from the raster store.
  *
  * @param aoi
  *      Spatial extent of the area of interest to extract
  * @param image_width
  *      Width of the resulting osg::Image (in pixels)
  * @param image_height
  *      Height of the resulting osg::Image (in pixels)
  * @return
  *      An osg::Image object. Caller is responsible for deleting the return object.
  */
 public abstract Mogre.Image createImage(GeoExtent aoi,
     uint image_width,
     uint image_height);
Ejemplo n.º 35
0
 /* (NOT YET IMPLEMENTED)
  * Extracts a height field from the raster store.
  *
  * @param aoi
  *      Spatial extent of the area of interest to extract
  * @return
  *      An OSG height field
  */
 public abstract osg.HeightField createHeightField(GeoExtent aoi);
Ejemplo n.º 36
0
        /**
         * Returns an extent representing the intersection two extents.
         * @param input
         *      Extent to intersect with this object.
         * @return
         *      Intersection extent.
         */
        public GeoExtent getIntersection(GeoExtent _rhs)
        {
            GeoExtent rhs = getSRS().transform(_rhs);

            if (rhs.getXMin() >= getXMax() || rhs.getXMax() <= getXMin() ||
                rhs.getYMin() >= getYMax() || rhs.getYMax() <= getYMin())
            {
                return GeoExtent.empty();
            }

            double xmin = rhs.getXMin() < getXMin() ? getXMin() : rhs.getXMin();
            double xmax = rhs.getXMax() > getXMax() ? getXMax() : rhs.getXMax();
            double ymin = rhs.getYMin() < getYMin() ? getYMin() : rhs.getYMin();
            double ymax = rhs.getYMax() > getYMax() ? getYMax() : rhs.getYMax();

            return new GeoExtent(xmin, ymin, xmax, ymax, getSRS());
        }
Ejemplo n.º 37
0
 public FeatureCursor getCursor(GeoExtent extent, bool match_exactly);
Ejemplo n.º 38
0
        /**
         * Returns true if another extent intersects this extent.
         * @param input
         *      Extent to test against this extent.
         */
        public bool intersects(GeoExtent input)
        {
            if (!isValid() || !input.isValid() || isEmpty() || input.isEmpty())
                return false;

            if (isInfinite() || input.isInfinite())
                return true;

            GeoPoint input_sw = getSRS().transform(input.getSouthwest());
            GeoPoint input_ne = getSRS().transform(input.getNortheast());

            bool isect;

            if (ne.X < input_sw.X || sw.X > input_ne.X ||
                ne.Y < input_sw.Y || sw.Y > input_ne.Y)
            {
                isect = false;
            }
            else
            {
                isect = true;
            }

            return isect;
        }
Ejemplo n.º 39
0
        protected void applyOverlayTexturing(osg.Geometry geom, Feature input, FilterEnv env)
        {
            GeoExtent tex_extent;

            if (getRasterOverlayScript() != null)
            {
                // if there's a raster script for this filter, we're applying textures per-feature:
                tex_extent = new GeoExtent(
                    input.getExtent().getSouthwest().getAbsolute(),
                    input.getExtent().getNortheast().getAbsolute());
            }
            else
            {
                // otherwise prepare the geometry for an overlay texture covering the entire working extent:
                tex_extent = env.getExtent();
            }

            float width = (float)tex_extent.getWidth();
            float height = (float)tex_extent.getHeight();

            // now visit the verts and calculate texture coordinates for each one.
            osg.Vec3Array verts = (osg.Vec3Array)(geom.getVertexArray());
            if (verts != null)
            {
                // if we are dealing with geocentric data, we will need to xform back to a real
                // projection in order to determine texture coords:
                GeoExtent tex_extent_geo;
                if (env.getInputSRS().isGeocentric())
                {
                    tex_extent_geo = new GeoExtent(
                        tex_extent.getSRS().getGeographicSRS().transform(tex_extent.getSouthwest()),
                        tex_extent.getSRS().getGeographicSRS().transform(tex_extent.getNortheast()));
                }

                osg.Vec2Array texcoords = new osg.Vec2Array(verts.size());
                for (int j = 0; j < verts.size(); j++)
                {
                    // xform back to raw SRS w.o. ref frame:
                    GeoPoint vert = new GeoPoint(verts[j], env.getInputSRS());
                    GeoPoint vert_map = vert.getAbsolute();
                    float tu, tv;
                    if (env.getInputSRS().isGeocentric())
                    {
                        tex_extent_geo.getSRS().transformInPlace(vert_map);
                        tu = (vert_map.X - tex_extent_geo.getXMin()) / width;
                        tv = (vert_map.Y - tex_extent_geo.getYMin()) / height;
                    }
                    else
                    {
                        tu = (vert_map.X - tex_extent.getXMin()) / width;
                        tv = (vert_map.Y - tex_extent.getYMin()) / height;
                    }
                    (*texcoords)[j].set(tu, tv);
                }
                geom.setTexCoordArray(0, texcoords);
            }

            // if we are applying the raster per-feature, do so now.
            // TODO: deprecate? will we ever use this versus the BuildNodesFilter overlay? maybe
            if (getRasterOverlayScript() != null)
            {
                ScriptResult r = env.getScriptEngine().run(getRasterOverlayScript(), input, env);
                if (r.isValid())
                {
                    RasterResource raster = env.getSession().getResources().getRaster(r.asString());
                    if (raster != null)
                    {
                        Image image = null;
                        std.stringstream builder;
                        builder << "rtex_" << input.getOID() << ".jpg"; //TODO: dds with DXT1 compression

                        osg.StateSet raster_ss = new osg.StateSet();
                        if (raster.applyToStateSet(raster_ss.get(), tex_extent, getRasterOverlayMaxSize(), out image))
                        {
                            image.setFileName(builder.str());
                            geom.setStateSet(raster_ss.get());

                            // add this as a skin resource so the compiler can properly localize and deploy it.
                            env.getResourceCache().addSkin(raster_ss.get());
                        }
                    }
                }
                else
                {
                    env.getReport().error(r.asString());
                }
            }
        }
Ejemplo n.º 40
0
 public override GeoExtent transform(GeoExtent input)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 41
0
 /**
  * Gets a reference to the entire list of parts.
  */
 public GeoPartList getParts()
 {
     extent_cache = GeoExtent.invalid();
     return(parts);
 }
Ejemplo n.º 42
0
 /**
  * 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;
 }
Ejemplo n.º 43
0
 /**
  * Creates a new, empty shape.
  *
  * @param type
  *      Shape type - see GeoShape::ShapeType
  * @param srs
  *      Spatial reference system for point data
  */
 public GeoShape(ShapeType _shape_type, SpatialReference _srs)
 {
     shape_type   = _shape_type;
     srs          = _srs;
     extent_cache = GeoExtent.invalid();
 }
 public override GeoExtent transform(GeoExtent input)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 45
0
 /**
  * Sets the reference terrain against which to compile.
  */
 public void setTerrain(Node _terrain, SpatialReference _terrain_srs, GeoExtent _terrain_extent)
 {
     terrain        = _terrain;
     terrain_srs    = (SpatialReference)_terrain_srs;
     terrain_extent = _terrain_extent;
 }
Ejemplo n.º 46
0
 public FeatureCursor getCursor(GeoExtent extent)
 {
     return getCursor(extent, false);
 }
Ejemplo n.º 47
0
 /**
  * Sets the reference terrain against which to compile.
  */
 public void setTerrain(Node _terrain, SpatialReference _terrain_srs)
 {
     setTerrain(_terrain, _terrain_srs, GeoExtent.infinite());
 }
Ejemplo n.º 48
0
        protected void applyOverlayTexturing(osg.Geometry geom, Feature input, FilterEnv env)
        {
            GeoExtent tex_extent;

            if (getRasterOverlayScript() != null)
            {
                // if there's a raster script for this filter, we're applying textures per-feature:
                tex_extent = new GeoExtent(
                    input.getExtent().getSouthwest().getAbsolute(),
                    input.getExtent().getNortheast().getAbsolute());
            }
            else
            {
                // otherwise prepare the geometry for an overlay texture covering the entire working extent:
                tex_extent = env.getExtent();
            }

            float width  = (float)tex_extent.getWidth();
            float height = (float)tex_extent.getHeight();

            // now visit the verts and calculate texture coordinates for each one.
            osg.Vec3Array verts = (osg.Vec3Array)(geom.getVertexArray());
            if (verts != null)
            {
                // if we are dealing with geocentric data, we will need to xform back to a real
                // projection in order to determine texture coords:
                GeoExtent tex_extent_geo;
                if (env.getInputSRS().isGeocentric())
                {
                    tex_extent_geo = new GeoExtent(
                        tex_extent.getSRS().getGeographicSRS().transform(tex_extent.getSouthwest()),
                        tex_extent.getSRS().getGeographicSRS().transform(tex_extent.getNortheast()));
                }

                osg.Vec2Array texcoords = new osg.Vec2Array(verts.size());
                for (int j = 0; j < verts.size(); j++)
                {
                    // xform back to raw SRS w.o. ref frame:
                    GeoPoint vert = new GeoPoint(verts[j], env.getInputSRS());
                    GeoPoint vert_map = vert.getAbsolute();
                    float    tu, tv;
                    if (env.getInputSRS().isGeocentric())
                    {
                        tex_extent_geo.getSRS().transformInPlace(vert_map);
                        tu = (vert_map.X - tex_extent_geo.getXMin()) / width;
                        tv = (vert_map.Y - tex_extent_geo.getYMin()) / height;
                    }
                    else
                    {
                        tu = (vert_map.X - tex_extent.getXMin()) / width;
                        tv = (vert_map.Y - tex_extent.getYMin()) / height;
                    }
                    (*texcoords)[j].set(tu, tv);
                }
                geom.setTexCoordArray(0, texcoords);
            }

            // if we are applying the raster per-feature, do so now.
            // TODO: deprecate? will we ever use this versus the BuildNodesFilter overlay? maybe
            if (getRasterOverlayScript() != null)
            {
                ScriptResult r = env.getScriptEngine().run(getRasterOverlayScript(), input, env);
                if (r.isValid())
                {
                    RasterResource raster = env.getSession().getResources().getRaster(r.asString());
                    if (raster != null)
                    {
                        Image            image = null;
                        std.stringstream builder;
                        builder << "rtex_" << input.getOID() << ".jpg"; //TODO: dds with DXT1 compression

                        osg.StateSet raster_ss = new osg.StateSet();
                        if (raster.applyToStateSet(raster_ss.get(), tex_extent, getRasterOverlayMaxSize(), out image))
                        {
                            image.setFileName(builder.str());
                            geom.setStateSet(raster_ss.get());

                            // add this as a skin resource so the compiler can properly localize and deploy it.
                            env.getResourceCache().addSkin(raster_ss.get());
                        }
                    }
                }
                else
                {
                    env.getReport().error(r.asString());
                }
            }
        }
Ejemplo n.º 49
0
        /*** 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;
        }
Ejemplo n.º 50
0
        // SpatialIndex

        /**
         * Gets a cursor that iterates over all the features that intersect
         * a spatial extent.
         *
         * @param query_extent
         *      Spatial extent to intersect
         * @param match_exactly
         *      If true, check for intersection at the shape level. If false, check
         *      for intersection at the extent (bounding box) level.
         */
        public FeatureCursor getCursor(GeoExtent extent)
        {
            return(getCursor(extent, false));
        }
Ejemplo n.º 51
0
 public osg.HeightField createHeightField(
       GeoExtent aoi);
Ejemplo n.º 52
0
        /**
         * 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;
        }
Ejemplo n.º 53
0
 /**
  * Returns true if an extent falls completely within this extent.
  * @param input
  *      Extent to test for containment.
  */
 public bool contains(GeoExtent input)
 {
     return
         input.isValid() &&
         contains(input.getSouthwest()) &&
         contains(input.getNortheast());
 }
Ejemplo n.º 54
0
        /**
         * Pushes source data onto the level of detail queue. Levels of detail are
         * interpreted from front to back.
         *
         * @param layer
         *      Feature layer from which to read source data
         * @param graph
         *      Filter graph to use to build scene graph
         * @param min_range
         *      Minimum visibility range of this level of detail
         * @param max_range
         *      Maximum visibility range of this level of detail
         * @param replace
         *      If true, this detail level will replace the ones before it. If false, it
         *      will join the scene graph without removing the previous levels.
         * @param depth
         *      Level of detail depth (0 = top level)
         * @param user_data
         *      User-defined data to pass to the cell compiler
         */
        public void push(FeatureLayer layer,
            FilterGraph graph,
            Properties env_props,
            ResourcePackager packager,
            float min_range,
            float max_range,
            bool replace,
            uint depth,
            object user_data)
        {
            if (layer != null)
            {
                // update the automatic AOI:
                if (!aoi_auto.isValid())
                    aoi_auto = layer.getExtent();
                else
                    aoi_auto.expandToInclude(layer.getExtent());

                // store the LOD definition:
                levels.Add(new MapLayerLevelOfDetail(
                    layer, graph, env_props, packager, min_range, max_range, replace, depth, user_data));

                grid_valid = false;
            }
        }
Ejemplo n.º 55
0
 /**
  * Adds a part to the shape and returns a reference to it.
  */
 public GeoPointList addPart(GeoPointList part)
 {
     extent_cache = GeoExtent.invalid();
     parts.Add(part);
     return(part);
 }