Package org.geotools.geopkg

Examples of org.geotools.geopkg.FeatureEntry


                if (!(schema instanceof SimpleFeatureType)) {
                    LOG.warning("Skipping feature type: " + ft.getName() + ", only simple schema are supported");
                    continue;
                }

                FeatureEntry fe = new FeatureEntry();
                fe.setTableName(ft.getName());
                fe.setIdentifier(ft.getTitle());
                fe.setDescription(ft.getAbstract());
                try {
                    fe.setBounds(ft.boundingBox());
                } catch (Exception e) {
                    throw new IOException(e);
                }
                fe.setSrid(srid(ft.getSRS()));

                GeometryDescriptor geom = schema.getGeometryDescriptor();
                if (geom != null) {
                    fe.setGeometryColumn(geom.getLocalName());
                    fe.setGeometryType(Geometries.getForBinding(
                        (Class<? extends com.vividsolutions.jts.geom.Geometry>) geom.getType().getBinding()));
                }

                gpkg.add(fe, (SimpleFeatureSource) ft.getFeatureSource(null, null), Filter.INCLUDE);
            }
View Full Code Here


    @Test
    public void testCreateFeatureEntry() throws Exception {
        ShapefileDataStore shp = new ShapefileDataStore(setUpShapefile());

        FeatureEntry entry = new FeatureEntry();
        geopkg.add(entry, shp.getFeatureSource(), null);

        assertTableExists("bugsites");

        //check metadata contents
View Full Code Here

    @Override
    public void postCreateTable(String schemaName, SimpleFeatureType featureType, Connection cx)
        throws SQLException, IOException {
    
        FeatureEntry fe = (FeatureEntry) featureType.getUserData().get(FeatureEntry.class);
        if (fe == null) {
            fe = new FeatureEntry();
            fe.setIdentifier(featureType.getTypeName());
            fe.setDescription(featureType.getTypeName());
            fe.setTableName(featureType.getTypeName());
            fe.setLastChange(new Date());
        }
       
        GeometryDescriptor gd = featureType.getGeometryDescriptor();
        if (gd != null) {
            fe.setGeometryColumn(gd.getLocalName());
            fe.setGeometryType(Geometries.getForBinding((Class) gd.getType().getBinding()));
        }

        CoordinateReferenceSystem crs = featureType.getCoordinateReferenceSystem();
        if (crs != null) {
            Integer epsgCode = null;
            try {
                epsgCode = CRS.lookupEpsgCode(crs, true);
            } catch (FactoryException e) {
                LOGGER.log(Level.WARNING, "Error looking up epsg code for " + crs, e);
            }
            if (epsgCode != null) {
                fe.setSrid(epsgCode);
            }
        }

        GeoPackage geopkg = geopkg();
        try {
            geopkg.addGeoPackageContentsEntry(fe);
            geopkg.addGeometryColumnsEntry(fe);

            //other geometry columns are possible
            for (PropertyDescriptor descr : featureType.getDescriptors()) {
                if (descr instanceof GeometryDescriptor) {
                    GeometryDescriptor gd1 = (GeometryDescriptor) descr;
                    if (gd1.getLocalName() != fe.getGeometryColumn()) {
                        FeatureEntry fe1 = new FeatureEntry();
                        fe1.init(fe);
                        fe1.setGeometryColumn(gd1.getLocalName());
                        fe1.setGeometryType(Geometries.getForBinding((Class) gd1.getType().getBinding()));
                        geopkg.addGeometryColumnsEntry(fe1);
                    }
                }
            }
        } catch (IOException e) {
View Full Code Here

        }
    }

    public Integer getGeometrySRID(String schemaName, String tableName, String columnName, Connection cx) throws SQLException {
        try {
            FeatureEntry fe = geopkg().feature(tableName);
            return fe != null ? fe.getSrid() : null;
        } catch (IOException e) {
            throw new SQLException(e);
        }
    }
View Full Code Here

        GeoPackage geopkg = new GeoPackage();
       
        for (FeatureCollection collection: featureCollection.getFeatures()) {
           
            FeatureEntry e = new FeatureEntry();
           
            if (! (collection instanceof SimpleFeatureCollection)) {
                throw new ServiceException("GeoPackage OutputFormat does not support Complex Features.");
            }

            SimpleFeatureCollection features = (SimpleFeatureCollectioncollection;
            FeatureTypeInfo meta = lookupFeatureType(features);
            if (meta != null) {
                // initialize entry metadata
                e.setIdentifier(meta.getTitle());
                e.setDescription(abstractOrDescription(meta));
            }

            geopkg.add(e, features);
        }
       
View Full Code Here

        GeoPackage gpkg = new GeoPackage(file);
       
        List<FeatureEntry> features = gpkg.features();
        assertEquals(2, features.size());
       
        FeatureEntry fe = features.get(0);
        assertEquals("Fifteen", fe.getTableName());
        assertEquals("fifteen description", fe.getDescription());
        assertEquals("f15", fe.getIdentifier());
        assertEquals(32615, fe.getSrid().intValue());
        assertEquals(500000, fe.getBounds().getMinX(), 0.0001);
        assertEquals(500000, fe.getBounds().getMinY(), 0.0001);
        assertEquals(500100, fe.getBounds().getMaxX(), 0.0001);
        assertEquals(500100, fe.getBounds().getMaxY(), 0.0001);
       
        SimpleFeatureReader fr = gpkg.reader(fe, null, null);
        assertEquals(1, fr.getFeatureType().getAttributeCount());
        assertEquals("pointProperty", fr.getFeatureType().getAttributeDescriptors().get(0).getLocalName());
        assertTrue(fr.hasNext());
        fr.next();
        fr.close();
       
        fe = features.get(1);
        assertEquals("Lakes", fe.getTableName());
        assertEquals("lakes description", fe.getDescription());
        assertEquals("lakes1", fe.getIdentifier());
       
        fr = gpkg.reader(fe, null, null);
        assertTrue(fr.hasNext());
        fr.next();
        fr.close();
View Full Code Here

       
        GeoPackage geopkg = createGeoPackage(os.toByteArray());
       
        //compare all feature collections
        for (FeatureCollection collection: fct.getFeatures()) {
            FeatureEntry e = new FeatureEntry();
            e.setTableName(collection.getSchema().getName().getLocalPart());
           
            SimpleFeatureReader reader = geopkg.reader(e, null, null);
           
            SimpleFeatureCollection sCollection = (SimpleFeatureCollection) collection;
           
View Full Code Here

               for (FeatureCollection collection: fc.getFeatures()) {                  
                   if (! (collection instanceof SimpleFeatureCollection)) {
                       throw new ServiceException("GeoPackage OutputFormat does not support Complex Features.");
                   }
                  
                   FeatureEntry e = new FeatureEntry();
                   e.setTableName(layer.getName());                  
                   addLayerMetadata(e, features);
                   ReferencedEnvelope bounds = collection.getBounds();
                   if (features.getBbox() != null){
                       bounds = ReferencedEnvelope.reference(bounds.intersection(features.getBbox()));
                   }
                  
                   e.setBounds(bounds);
                 
                   gpkg.add(e, (SimpleFeatureCollectioncollection);
               }
              
           } else if (layer.getType() == LayerType.TILES) {
View Full Code Here

TOP

Related Classes of org.geotools.geopkg.FeatureEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.