Пример #1
0
 /**
  * Gets the layer extent that this compiler will use. If this is set
  * to GeoExtent.Infinite, that compiler will query the feature layer
  * for its full extent and use that as the AOI.
  */
 public GeoExtent getAreaOfInterest(FeatureLayer layer)
 {
     if (aoi_xmin < aoi_xmax && aoi_ymin < aoi_ymax)
     {
         return(new GeoExtent(aoi_xmin, aoi_ymin, aoi_xmax, aoi_ymax, layer.getSRS()));
     }
     else
     {
         return(layer.getExtent());
     }
 }
Пример #2
0
        public Node compile(FeatureLayer layer, FeatureCursor cursor, FilterGraph graph)
        {
            osg.ref_ptr <FilterEnv> env = getSession().createFilterEnv();
            env.setExtent(getAreaOfInterest(layer));
            env.setInputSRS(layer.getSRS());
            env.setTerrainNode(terrain.get());
            env.setTerrainSRS(terrain_srs.get());
            env.setTerrainReadCallback(read_cb.get());

            osg.Group *       output;
            FilterGraphResult r = graph.computeNodes(cursor, env.get(), output);

            return(r.isOK() ? output : NULL);
        }
Пример #3
0
        /**
         * Creates a feature layer by connecting to a feature store.
         *
         * @param uri
         *      URI of the feature store to use as the underlying data
         *      source for this layer.
         * @return
         *      A new feature layer. Caller is responsible for deleting
         *      the return object.
         */
        public FeatureLayer createFeatureLayer(string uri)
        {
            FeatureLayer result = null;

            if (getFeatureStoreFactory() != null)
            {
                FeatureStore store = getFeatureStoreFactory().connectToFeatureStore(uri);

                if (store != null && store.isReady())
                {
                    result = new FeatureLayer(store);

#if TODO
                    // if the store doesn't provide a spatial reference, try to load one from
                    // a PRJ file:
                    if (result != null && result.getSRS() == null)
                    {
                        if (osgDB.fileExists(uri)) // make sure it's a file:
                        {
                            string  prj_file = osgDB.getNameLessExtension(uri) + ".prj";
                            fstream istream;
                            istream.open(prj_file.c_str());
                            if (istream.is_open())
                            {
                                istream.seekg(0, std.ios.end);
                                int length = istream.tellg();
                                istream.seekg(0, std.ios.beg);
                                char[] buf = new char[length];
                                istream.read(buf, length);
                                istream.close();
                                string           prj     = buf;
                                SpatialReference prj_srs =
                                    Registry.instance().getSRSFactory().createSRSfromWKT(prj);
                                result.setSRS(prj_srs);
                            }
                        }
                    }
#endif
                }
            }
            return(result);
        }
Пример #4
0
        /**
         * Creates a feature layer by connecting to a feature store.
         *
         * @param uri
         *      URI of the feature store to use as the underlying data
         *      source for this layer.
         * @return
         *      A new feature layer. Caller is responsible for deleting
         *      the return object.
         */
        public FeatureLayer createFeatureLayer(string uri)
        {
            FeatureLayer result = null;
            if (getFeatureStoreFactory() != null)
            {
                FeatureStore store = getFeatureStoreFactory().connectToFeatureStore(uri);

                if (store != null && store.isReady())
                {
                    result = new FeatureLayer(store);

            #if TODO
                    // if the store doesn't provide a spatial reference, try to load one from
                    // a PRJ file:
                    if (result != null && result.getSRS() == null)
                    {
                        if (osgDB.fileExists(uri)) // make sure it's a file:
                        {
                            string prj_file = osgDB.getNameLessExtension(uri) + ".prj";
                            fstream istream;
                            istream.open(prj_file.c_str());
                            if (istream.is_open())
                            {
                                istream.seekg(0, std.ios.end);
                                int length = istream.tellg();
                                istream.seekg(0, std.ios.beg);
                                char[] buf = new char[length];
                                istream.read(buf, length);
                                istream.close();
                                string prj = buf;
                                SpatialReference prj_srs =
                                 Registry.instance().getSRSFactory().createSRSfromWKT(prj);
                                result.setSRS(prj_srs);
                            }
                        }
                    }
            #endif
                }
            }
            return result;
        }