Class SpatialDbsImportUtils
- java.lang.Object
-
- org.hortonmachine.gears.spatialite.SpatialDbsImportUtils
-
public class SpatialDbsImportUtils extends Object
Import utilities.- Author:
- Andrea Antonello (www.hydrologis.com)
-
-
Field Summary
Fields Modifier and Type Field Description static StringGEOMFIELD_FOR_SHAPEFILE
-
Constructor Summary
Constructors Constructor Description SpatialDbsImportUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcreateTableFromSchema(ASpatialDb db, org.opengis.feature.simple.SimpleFeatureType schema, String newTableName, String forceSrid, boolean avoidSpatialIndex)Create a spatial table using a schema.static StringcreateTableFromShp(ASpatialDb db, File shapeFile, String newTableName, String forceSrid, boolean avoidSpatialIndex)Create a spatial table using a shapefile as schema.static booleanimportFeatureCollection(ASpatialDb db, org.geotools.data.simple.SimpleFeatureCollection featureCollection, String tableName, int limit, boolean useFromTextForGeom, IHMProgressMonitor pm)Import a featureCollection into a table.static booleanimportShapefile(ASpatialDb db, File shapeFile, String tableName, int limit, boolean useFromTextForGeom, IHMProgressMonitor pm)Import a shapefile into a table.static org.geotools.feature.DefaultFeatureCollectiontableGeomsToFeatureFCollection(ASpatialDb db, String tableName, int forceSrid, String geomPrefix, String geomPostfix, String whereStr)static org.geotools.feature.DefaultFeatureCollectiontableToFeatureFCollection(ASpatialDb db, String tableName, int featureLimit, int forceSrid, String whereStr)Get a table as featurecollection.
-
-
-
Field Detail
-
GEOMFIELD_FOR_SHAPEFILE
public static final String GEOMFIELD_FOR_SHAPEFILE
- See Also:
- Constant Field Values
-
-
Method Detail
-
createTableFromShp
public static String createTableFromShp(ASpatialDb db, File shapeFile, String newTableName, String forceSrid, boolean avoidSpatialIndex) throws Exception
Create a spatial table using a shapefile as schema.- Parameters:
db- the database to use.shapeFile- the shapefile to use.newTableName- the new name of the table. If null, the shp name is used.forceSrid- an optional srid to force the table to.avoidSpatialIndex- iftrue, no spatial index will be created. This is useful if many records have to be inserted and the index will be created later manually.- Returns:
- the name of the created table.
- Throws:
Exception
-
createTableFromSchema
public static String createTableFromSchema(ASpatialDb db, org.opengis.feature.simple.SimpleFeatureType schema, String newTableName, String forceSrid, boolean avoidSpatialIndex) throws Exception
Create a spatial table using a schema.- Parameters:
db- the database to use.schema- the schema to use.newTableName- the new name of the table. If null, the shp name is used.forceSrid- an optional srid to force the table to.avoidSpatialIndex- iftrue, no spatial index will be created. This is useful if many records have to be inserted and the index will be created later manually.- Returns:
- the name of the created table.
- Throws:
Exception
-
importShapefile
public static boolean importShapefile(ASpatialDb db, File shapeFile, String tableName, int limit, boolean useFromTextForGeom, IHMProgressMonitor pm) throws Exception
Import a shapefile into a table.- Parameters:
db- the database to use.shapeFile- the shapefile to import.tableName- the name of the table to import to.limit- if > 0, a limit to the imported features is applied.useFromTextForGeom- if true, the wkt form is used to insert geometries.pm- the progress monitor.- Returns:
false, is an error occurred.- Throws:
Exception
-
importFeatureCollection
public static boolean importFeatureCollection(ASpatialDb db, org.geotools.data.simple.SimpleFeatureCollection featureCollection, String tableName, int limit, boolean useFromTextForGeom, IHMProgressMonitor pm) throws Exception
Import a featureCollection into a table.- Parameters:
db- the database to use.featureCollection- the featureCollection to import.tableName- the name of the table to import to.limit- if > 0, a limit to the imported features is applied.useFromTextForGeom- if true, the wkt form is used to insert geometries.pm- the progress monitor.- Returns:
false, is an error occurred.- Throws:
Exception
-
tableToFeatureFCollection
public static org.geotools.feature.DefaultFeatureCollection tableToFeatureFCollection(ASpatialDb db, String tableName, int featureLimit, int forceSrid, String whereStr) throws SQLException, Exception
Get a table as featurecollection.- Parameters:
db- the database.tableName- the table to use.featureLimit- limit in feature or -1.forceSrid- a srid to force to or -1.whereStr- an optional where condition string.- Returns:
- the extracted featurecollection.
- Throws:
SQLExceptionException
-
tableGeomsToFeatureFCollection
public static org.geotools.feature.DefaultFeatureCollection tableGeomsToFeatureFCollection(ASpatialDb db, String tableName, int forceSrid, String geomPrefix, String geomPostfix, String whereStr) throws SQLException, Exception
- Throws:
SQLExceptionException
-
-