Java Code Examples for org.geotools.data.DataStoreFinder#getDataStore()
The following examples show how to use
org.geotools.data.DataStoreFinder#getDataStore() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestUtils.java From geowave with Apache License 2.0 | 6 votes |
public static SimpleFeature resourceToFeature(final URL filterResource) throws IOException { final Map<String, Object> map = new HashMap<>(); DataStore dataStore = null; map.put("url", filterResource); final SimpleFeature savedFilter; SimpleFeatureIterator sfi = null; try { dataStore = DataStoreFinder.getDataStore(map); if (dataStore == null) { LOGGER.error("Could not get dataStore instance, getDataStore returned null"); throw new IOException("Could not get dataStore instance, getDataStore returned null"); } // just grab the first feature and use it as a filter sfi = dataStore.getFeatureSource(dataStore.getNames().get(0)).getFeatures().features(); savedFilter = sfi.next(); } finally { if (sfi != null) { sfi.close(); } if (dataStore != null) { dataStore.dispose(); } } return savedFilter; }
Example 2
Source File: ShpConnector.java From TripleGeo with GNU General Public License v3.0 | 6 votes |
/** * Loads the shape file from the configuration path and returns the * feature collection associated according to the configuration. * * @param shapePath with the path to the shapefile. * @param featureString with the featureString to filter. * * @return FeatureCollection with the collection of features filtered. */ private FeatureCollection getShapeFileFeatureCollection(String shapePath, String featureString) throws IOException { File file = new File(shapePath); // Create the map with the file URL to be passed to DataStore. Map map = new HashMap(); try { map.put("url", file.toURL()); } catch (MalformedURLException ex) { Logger.getLogger(ShpConnector.class.getName()).log(Level.SEVERE, null, ex); } if (map.size() > 0) { DataStore dataStore = DataStoreFinder.getDataStore(map); FeatureSource featureSource = dataStore.getFeatureSource(featureString); return featureSource.getFeatures(); } return null; }
Example 3
Source File: MultiPolygons.java From amodeus with GNU General Public License v2.0 | 6 votes |
private static Set<MultiPolygon> initializeFrom(File shapeFile) throws IOException { URL shapeFileURL = shapeFile.toURI().toURL(); Map<String, URL> inputMap = new HashMap<>(); inputMap.put("url", shapeFileURL); DataStore dataStore = DataStoreFinder.getDataStore(inputMap); SimpleFeatureSource featureSource = dataStore.getFeatureSource(dataStore.getTypeNames()[0]); SimpleFeatureCollection collection = DataUtilities.collection(featureSource.getFeatures()); dataStore.dispose(); Set<MultiPolygon> polygons = new HashSet<>(); SimpleFeatureIterator iterator = collection.features(); while (iterator.hasNext()) polygons.add((MultiPolygon) iterator.next().getDefaultGeometry()); return polygons; }
Example 4
Source File: ShapeFileParser.java From GeoTriples with Apache License 2.0 | 6 votes |
public List<GeneralResultRow> getData(String tablename) throws Exception { if (cacheList.containsKey(tablename)) { return cacheList.get(tablename); } else if (cacheList.containsKey(tablename.replaceAll("_geometry", ""))) { return cacheList.get(tablename.replaceAll("_geometry", "")); } DataStore dataStore = null; List<GeneralResultRow> result = null; try { Map<String, URL> connect = new HashMap<String, URL>(); connect.put("url", shapefile.toURI().toURL()); dataStore = DataStoreFinder.getDataStore(connect); FeatureSource<?, ?> featureSource = dataStore.getFeatureSource(tablename .replaceAll("_geometry", "")); if (featureSource != null) { result = getData(featureSource); } } catch (Exception ex) { ex.printStackTrace(); } finally { dataStore.dispose(); } cacheList.put(tablename.replaceAll("_geometry", ""), result); return result; }
Example 5
Source File: DatabaseClient.java From sldeditor with GNU General Public License v3.0 | 5 votes |
@Override public boolean connect() { connected = false; Map<String, Object> params = getDBConnectionParams(); try { DataStore dataStore = DataStoreFinder.getDataStore(params); if (dataStore != null) { connectToDatastore(dataStore); } else { String message = String.format( "%s : %s", Localisation.getString( DatabaseClient.class, "DatabaseClient.noDriver"), (connection == null) ? "No connection" : connection.getConnectionName()); ConsoleManager.getInstance().error(this, message); } } catch (IOException e) { ConsoleManager.getInstance().exception(this, e); } return connected; }
Example 6
Source File: DataSourceInfoTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getFeatures()}. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testGetFeatures() { URL url = SLDEditorFile.class .getClassLoader() .getResource("point/sld/shp/sld_cookbook_point.shp"); Map map = new HashMap(); map.put("url", url); DataStore dataStore; try { dataStore = DataStoreFinder.getDataStore(map); DataSourceInfo dsInfo = new DataSourceInfo(); String typeName = dataStore.getTypeNames()[0]; dsInfo.setTypeName(typeName); SimpleFeatureSource source = dataStore.getFeatureSource(typeName); SimpleFeatureType schema = source.getSchema(); assertNull(dsInfo.getFeatures()); dsInfo.setSchema(schema); assertNull(dsInfo.getFeatures()); dsInfo.setDataStore(dataStore); assertTrue(dsInfo.getFeatures() != null); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } }
Example 7
Source File: DataSourceInfoTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getFeatureCollection()}. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testGetFeatureCollection() { URL url = SLDEditorFile.class .getClassLoader() .getResource("point/sld/shp/sld_cookbook_point.shp"); Map map = new HashMap(); map.put("url", url); DataStore dataStore; try { dataStore = DataStoreFinder.getDataStore(map); DataSourceInfo dsInfo = new DataSourceInfo(); String typeName = dataStore.getTypeNames()[0]; dsInfo.setTypeName(typeName); SimpleFeatureSource source = dataStore.getFeatureSource(typeName); SimpleFeatureType schema = source.getSchema(); assertNull(dsInfo.getGeometryFieldName()); dsInfo.setSchema(schema); assertEquals("the_geom", dsInfo.getGeometryFieldName()); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } }
Example 8
Source File: DataSourceInfoTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.datasource.impl.DataSourceInfo#getPropertyDescriptorList()}. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testGetPropertyDescriptorList() { URL url = SLDEditorFile.class .getClassLoader() .getResource("point/sld/shp/sld_cookbook_point.shp"); Map map = new HashMap(); map.put("url", url); DataStore dataStore; try { dataStore = DataStoreFinder.getDataStore(map); DataSourceInfo dsInfo = new DataSourceInfo(); String typeName = dataStore.getTypeNames()[0]; dsInfo.setTypeName(typeName); SimpleFeatureSource source = dataStore.getFeatureSource(typeName); SimpleFeatureType schema = source.getSchema(); assertNull(dsInfo.getPropertyDescriptorList()); dsInfo.setSchema(schema); Collection<PropertyDescriptor> fieldList = dsInfo.getPropertyDescriptorList(); assertTrue(fieldList.size() == 3); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } }
Example 9
Source File: DataSourceInfoTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getGeometryFieldName()}. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testGetGeometryFieldName() { URL url = SLDEditorFile.class .getClassLoader() .getResource("point/sld/shp/sld_cookbook_point.shp"); Map map = new HashMap(); map.put("url", url); DataStore dataStore; try { dataStore = DataStoreFinder.getDataStore(map); DataSourceInfo dsInfo = new DataSourceInfo(); String typeName = dataStore.getTypeNames()[0]; dsInfo.setTypeName(typeName); SimpleFeatureSource source = dataStore.getFeatureSource(typeName); SimpleFeatureType schema = source.getSchema(); assertNull(dsInfo.getGeometryFieldName()); dsInfo.setSchema(schema); assertEquals("the_geom", dsInfo.getGeometryFieldName()); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } }
Example 10
Source File: FeatureFigureEditorApp.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private static FeatureSource<SimpleFeatureType, SimpleFeature> getFeatureSource(File file) throws IOException { Map<String, Object> map = new HashMap<String, Object>(); map.put(ShapefileDataStoreFactory.URLP.key, file.toURI().toURL()); map.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, Boolean.TRUE); DataStore shapefileStore = DataStoreFinder.getDataStore(map); String typeName = shapefileStore.getTypeNames()[0]; // Shape files do only have one type name FeatureSource<SimpleFeatureType, SimpleFeature> featureSource; featureSource = shapefileStore.getFeatureSource(typeName); return featureSource; }
Example 11
Source File: GeoMesaGeoIndexer.java From rya with Apache License 2.0 | 5 votes |
private static DataStore createDataStore(final Configuration conf) throws IOException { // get the configuration parameters final Instance instance = ConfigUtils.getInstance(conf); final boolean useMock = instance instanceof MockInstance; final String instanceId = instance.getInstanceName(); final String zookeepers = instance.getZooKeepers(); final String user = ConfigUtils.getUsername(conf); final String password = ConfigUtils.getPassword(conf); final String auths = ConfigUtils.getAuthorizations(conf).toString(); final String tableName = getTableName(conf); final int numParitions = OptionalConfigUtils.getGeoNumPartitions(conf); final String featureSchemaFormat = "%~#s%" + numParitions + "#r%" + FEATURE_NAME + "#cstr%0,3#gh%yyyyMMdd#d::%~#s%3,2#gh::%~#s%#id"; // build the map of parameters final Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put("instanceId", instanceId); params.put("zookeepers", zookeepers); params.put("user", user); params.put("password", password); params.put("auths", auths); params.put("tableName", tableName); params.put("indexSchemaFormat", featureSchemaFormat); params.put("useMock", Boolean.toString(useMock)); // fetch the data store from the finder return DataStoreFinder.getDataStore(params); }
Example 12
Source File: GamaSqlConnection.java From gama with GNU General Public License v3.0 | 5 votes |
public DataStore Connect(final IScope scope) throws Exception { final Map<String, Object> connectionParameters = createConnectionParams(scope); DataStore dStore; dStore = DataStoreFinder.getDataStore(connectionParameters); // get // connection // DEBUG.LOG("data store postgress:" + dStore); if (dStore == null) { throw new IOException("Can't connect to " + database); } return dStore; }
Example 13
Source File: ShapefileMappingGenerator.java From GeoTriples with Apache License 2.0 | 4 votes |
public void run() throws IOException { Map<String, URL> connect = new HashMap<String, URL>(); connect.put("url", new File(pathToShapefile).toURI().toURL()); DataStore dataStore = DataStoreFinder.getDataStore(connect); String[] typeNames = dataStore.getTypeNames(); for (int i = 0; i < typeNames.length; ++i) { String typeName = typeNames[i]; triplesMaps.put(typeName, ""); triplesMaps.put(typeName, triplesMaps.get(typeName) + printTriplesMap(typeName)); triplesMaps.put(typeName, triplesMaps.get(typeName) + printLogicalSource(typeName)); triplesMaps.put(typeName, triplesMaps.get(typeName) + printSubjectMap(baseURI, typeName)); FeatureSource<?, ?> featureSource = dataStore.getFeatureSource(typeName); FeatureType ft = featureSource.getSchema(); String typeNameGeo = typeNames[i] + "_Geometry"; for (PropertyDescriptor property : ft.getDescriptors()) { String identifier = property.getName().getLocalPart(); if (identifier.equals("the_geom")) { continue; } String datatype = TranslateDataTypeToXSD((property.getType().getBinding().getName())); Query q = new Query(); triplesMaps.put(typeName, triplesMaps.get(typeName) + printPredicateObjectMap(identifier, identifier, datatype, typeName)); } // triplesMaps.put(typeName, // triplesMaps.get(typeName) + printPredicateObjectMap(true, // "hasGeometry", // baseURI + (baseURI.endsWith("/") ? "" : "/") + typeNameGeo + // "/{GeoTriplesID}", null, // typeName, true)); triplesMaps .put(typeName, triplesMaps.get(typeName) + printPredicateObjectMap(true, "hasGeometry", baseURI + (baseURI.endsWith("/") ? "" : "/") + typeName + "/Geometry/{GeoTriplesID}", null, null, "ogc", null, typeName, true, false)); triplesMaps.put(typeNameGeo, ""); triplesMaps.put(typeNameGeo, triplesMaps.get(typeNameGeo) + printTriplesMap(typeNameGeo)); triplesMaps.put(typeNameGeo, triplesMaps.get(typeNameGeo) + printLogicalSource(typeName)); triplesMaps.put(typeNameGeo, triplesMaps.get(typeNameGeo) + printSubjectMap(baseURI, typeName, null, true)); triplesMaps.put(typeNameGeo, triplesMaps.get(typeNameGeo) + printGEOPredicateObjectMaps()); } printmapping(); printontology(); }
Example 14
Source File: TestUtils.java From geowave with Apache License 2.0 | 4 votes |
public static ExpectedResults getExpectedResults( final URL[] expectedResultsResources, final CoordinateReferenceSystem crs) throws IOException { final Map<String, Object> map = new HashMap<>(); DataStore dataStore = null; final Set<Long> hashedCentroids = new HashSet<>(); int expectedResultCount = 0; final MathTransform mathTransform = transformFromCrs(crs); final TWKBWriter writer = new TWKBWriter(); final TWKBReader reader = new TWKBReader(); for (final URL expectedResultsResource : expectedResultsResources) { map.put("url", expectedResultsResource); SimpleFeatureIterator featureIterator = null; try { dataStore = DataStoreFinder.getDataStore(map); if (dataStore == null) { LOGGER.error("Could not get dataStore instance, getDataStore returned null"); throw new IOException("Could not get dataStore instance, getDataStore returned null"); } final SimpleFeatureCollection expectedResults = dataStore.getFeatureSource(dataStore.getNames().get(0)).getFeatures(); expectedResultCount += expectedResults.size(); // unwrap the expected results into a set of features IDs so its // easy to check against featureIterator = expectedResults.features(); while (featureIterator.hasNext()) { final SimpleFeature feature = featureIterator.next(); final Geometry geometry = (Geometry) feature.getDefaultGeometry(); // TODO: Geometry has to be serialized and deserialized here // to make the centroid match the one coming out of the // database. final long centroid = hashCentroid( reader.read( writer.write( mathTransform != null ? JTS.transform(geometry, mathTransform) : geometry))); hashedCentroids.add(centroid); } } catch (MismatchedDimensionException | TransformException | ParseException e) { LOGGER.warn("Unable to transform geometry", e); Assert.fail("Unable to transform geometry to CRS: " + crs.toString()); } finally { IOUtils.closeQuietly(featureIterator); if (dataStore != null) { dataStore.dispose(); } } } return new ExpectedResults(hashedCentroids, expectedResultCount); }
Example 15
Source File: DataStoreFactory.java From geomajas-project-server with GNU Affero General Public License v3.0 | 4 votes |
/** * Creates a suitable {@link DataStore} for the specified parameters. * * @param parameters list of GeoTools parameters. * @return data store, never null * @throws IOException could not create data store */ public static DataStore create(Map<String, Object> parameters) throws IOException { Object url = parameters.get(ShapefileDataStoreFactory.URLP.key); Logger log = LoggerFactory.getLogger(DataStoreFactory.class); if (url instanceof String) { parameters.put(ShapefileDataStoreFactory.URLP.key, ResourceUtils.getURL((String) url).toExternalForm()); } if (DATASTORE_CACHE.containsKey(parameters)) { return DATASTORE_CACHE.get(parameters); } DataStore store = DataStoreFinder.getDataStore(parameters); Object typed = parameters.get(USE_TYPED_FIDS); if (typed instanceof String) { Boolean t = Boolean.valueOf((String) typed); if (!t) { if (store != null) { log.warn("Non-typed FIDs are only supported by first-generation JDBC datastores, " + "using default fid format for datastore class " + store.getClass().getName()); } } } if (null == store) { StringBuilder availableStr = new StringBuilder(); StringBuilder missingStr = new StringBuilder(); Iterator<DataStoreFactorySpi> all = DataStoreFinder.getAllDataStores(); while (all.hasNext()) { DataStoreFactorySpi factory = all.next(); if (!factory.isAvailable()) { log.warn("Datastore factory " + factory.getDisplayName() + "(" + factory.getDescription() + ") is not available"); if (missingStr.length() != 0) { missingStr.append(","); } missingStr.append(factory.getDisplayName()); } else { if (availableStr.length() != 0) { availableStr.append(","); } availableStr.append(factory.getDisplayName()); } } throw new IOException( "No datastore found. Possible causes are missing factory or missing library for your datastore" + " (e.g. database driver).\nCheck the isAvailable() method of your" + " DataStoreFactory class to find out which libraries are needed.\n" + "Unavailable factories : " + missingStr + "\n" + "Available factories : " + availableStr + "\n"); } DATASTORE_CACHE.put(parameters, store); return store; }
Example 16
Source File: ShapeFileParserGDAL.java From GeoTriples with Apache License 2.0 | 4 votes |
public List<TableDef> getTablesDefs() throws Exception { DataStore dataStore = null; List<ColumnDef> columns = null; TableDef onlytable = null; Set<Key> primkeys = new HashSet<Key>(); List<TableDef> tables = new ArrayList<TableDef>(); try { Map<String, URL> connect = new HashMap<String, URL>(); connect.put("url", shapefile.toURI().toURL()); dataStore = DataStoreFinder.getDataStore(connect); String[] typeNames = dataStore.getTypeNames(); for (int i = 0; i < typeNames.length; ++i) { String typeName = typeNames[i]; FeatureSource<?, ?> featureSource = dataStore.getFeatureSource(typeName); FeatureType ft = featureSource.getSchema(); columns = new ArrayList<ColumnDef>(); for (PropertyDescriptor property : ft.getDescriptors()) { Identifier identifier = Identifier.createDelimited(property.getName().getLocalPart()); DataType datatype = TableDefUtils .TranslateDataTypeToSQLType((property.getType().getBinding().getName())); ColumnDef col = new ColumnDef(identifier, datatype, property.isNillable()); columns.add(col); } // Identifier identifier = Identifier.createDelimited("gid"); // ColumnDef col = new ColumnDef(identifier, // TranslateDataTypeToSQLType("Int"), false); // columns.add(col); // primkeys.add(Key.create(identifier)); TableName tablename = TableName.create(null, null, Identifier.create(true, dataStore.getTypeNames()[0])); onlytable = new TableDef(tablename, columns, null, primkeys, new HashSet<ForeignKey>()); tables.add(onlytable); } } catch (Throwable e) { throw new Exception(e.getMessage()); } finally { dataStore.dispose(); } return tables; }
Example 17
Source File: ShapeFileParser.java From GeoTriples with Apache License 2.0 | 4 votes |
public List<TableDef> getTablesDefs() throws Exception { DataStore dataStore = null; List<ColumnDef> columns = null; TableDef onlytable = null; Set<Key> primkeys = new HashSet<Key>(); List<TableDef> tables = new ArrayList<TableDef>(); try { Map<String, URL> connect = new HashMap<String, URL>(); connect.put("url", shapefile.toURI().toURL()); dataStore = DataStoreFinder.getDataStore(connect); String[] typeNames = dataStore.getTypeNames(); for (int i = 0; i < typeNames.length; ++i) { String typeName = typeNames[i]; FeatureSource<?, ?> featureSource = dataStore .getFeatureSource(typeName); FeatureType ft = featureSource.getSchema(); columns = new ArrayList<ColumnDef>(); for (PropertyDescriptor property : ft.getDescriptors()) { Identifier identifier = Identifier.createDelimited(property .getName().getLocalPart()); DataType datatype = TableDefUtils.TranslateDataTypeToSQLType((property .getType().getBinding().getName())); ColumnDef col = new ColumnDef(identifier, datatype, property.isNillable()); columns.add(col); } //Identifier identifier = Identifier.createDelimited("gid"); //ColumnDef col = new ColumnDef(identifier, TranslateDataTypeToSQLType("Int"), false); //columns.add(col); //primkeys.add(Key.create(identifier)); TableName tablename = TableName.create(null, null, Identifier.create(true, dataStore.getTypeNames()[0])); onlytable = new TableDef(tablename, columns, null, primkeys, new HashSet<ForeignKey>()); tables.add(onlytable); } } catch (Throwable e) { throw new Exception(e.getMessage()); } finally { dataStore.dispose(); } return tables; }
Example 18
Source File: CreateExternalDataSource.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Connect. * * @param typeName the type name * @param geometryFieldName the geometry field name * @param editorFile the editor file * @return the list of datastores */ @Override public List<DataSourceInfo> connect( String typeName, String geometryFieldName, SLDEditorFileInterface editorFile) { List<DataSourceInfo> dataSourceInfoList = new ArrayList<>(); dataSourceInfoList.add(dsInfo); dsInfo.reset(); if (editorFile != null) { SLDDataInterface sldData = editorFile.getSLDData(); DataSourcePropertiesInterface dataSourceProperties = sldData.getDataSourceProperties(); Map<String, Object> map = dataSourceProperties.getConnectionProperties(); if (dataSourceProperties.hasPassword()) { String password = dataSourceProperties.getPassword(); if (password == null) { dataSourceProperties.setPassword("dummy password"); map = dataSourceProperties.getConnectionProperties(); } } DataStore dataStore = null; try { dataStore = DataStoreFinder.getDataStore(map); if (dataStore != null) { // Try connecting to a vector data source connectToVectorDataSource(typeName, dataStore); } else { // Try connecting to a raster data source connectToRasterDataSource(map); } } catch (IOException e) { ConsoleManager.getInstance().exception(this, e); } dsInfo.setDataStore(dataStore); if (!dsInfo.hasData()) { ConsoleManager.getInstance() .error( this, Localisation.getField( CreateExternalDataSource.class, "CreateExternalDataSource.failedToConnect") + dataSourceProperties.getDebugConnectionString()); } } return dataSourceInfoList; }
Example 19
Source File: AbstractGeotoolsDataStoreImporter.java From TomboloDigitalConnector with MIT License | 4 votes |
protected DataStore getDataStoreForDatasource(Datasource datasource) throws IOException { return DataStoreFinder.getDataStore(getParamsForDatasource(datasource)); }
Example 20
Source File: SeaRouting.java From searoute with European Union Public License 1.2 | 4 votes |
public SeaRouting(int resKM) { try { //load marnet DataStore store = null; SimpleFeatureCollection fc = null; /*try { URL url = getClass().getResource("/marnet/marnet_plus_"+resKM+"km.gpkg"); HashMap<String, Object> map = new HashMap<>(); map.put(GeoPkgDataStoreFactory.DBTYPE.key, "geopkg"); map.put(GeoPkgDataStoreFactory.DATABASE.key, url.getFile()); map.put("url", url); store = DataStoreFinder.getDataStore(map); fc = store.getFeatureSource(store.getTypeNames()[0]).getFeatures(); } catch (Exception e) {*/ //URL url = new URL(path); HashMap<String, Object> map = new HashMap<>(); map.put(GeoPkgDataStoreFactory.DBTYPE.key, "geopkg"); map.put(GeoPkgDataStoreFactory.DATABASE.key, "marnet/marnet_plus_"+resKM+"km.gpkg"); map.put("url", "marnet/marnet_plus_"+resKM+"km.gpkg"); store = DataStoreFinder.getDataStore(map); fc = store.getFeatureSource(store.getTypeNames()[0]).getFeatures(); //} //build graph FeatureIterator<?> it = fc.features(); FeatureGraphGenerator gGen = new FeatureGraphGenerator(new LineStringGraphGenerator()); while(it.hasNext()) gGen.add(it.next()); g = gGen.getGraph(); it.close(); store.dispose(); } catch (Exception e) { e.printStackTrace(); } //link nodes around the globe for(Object o : g.getNodes()){ Node n = (Node)o; Coordinate c = ((Point)n.getObject()).getCoordinate(); if(c.x==180) { Node n_ = getNode(new Coordinate(-c.x,c.y)); if(LOGGER.isTraceEnabled()) LOGGER.trace(c + " -> " + ((Point)n_.getObject()).getCoordinate()); BasicEdge be = new BasicEdge(n, n_); n.add(be); n_.add(be); g.getEdges().add(be); } } //define weighters defaultWeighter = buildEdgeWeighter(true, true); noSuezWeighter = buildEdgeWeighter(false, true); noPanamaWeighter = buildEdgeWeighter(true, false); noSuezNoPanamaWeighter = buildEdgeWeighter(false, false); }