@Test public void testCreateGeometry() { List<Coordinate[]> coordList = null; Geometry geom = null; String idObj = null; try { idObj = "Objet_434514"; eVecS1.geoType = "POINT"; coordList = eVecS1.getRelation(idObj); geom = eVecS1.createGeometry(coordList, idObj); assertTrue("geom should be an instance of Point", geom instanceof Point); } catch (IOException e) { assertFalse(e.getMessage(), true); } try { idObj = "Objet_3351611"; eVecS1.geoType = "LINESTRING"; coordList = eVecS1.getRelation(idObj); geom = eVecS1.createGeometry(coordList, idObj); assertTrue("geom should be an instance of LineString", geom instanceof LineString); } catch (IOException e) { assertFalse(e.getMessage(), true); } try { idObj = "Objet_647020"; eVecS1.geoType = "POLYGON"; coordList = eVecS1.getRelation(idObj); geom = eVecS1.createGeometry(coordList, idObj); assertTrue("geom should be an instance of Polygon", geom instanceof Polygon); } catch (IOException e) { assertFalse(e.getMessage(), true); } try { idObj = "Objet_966450"; eVecT3.geoType = "MULTIPOLYGON"; coordList = eVecT3.getRelation(idObj); geom = eVecT3.createGeometry(coordList, idObj); assertTrue("geom should be an instance of MultiPolygon", geom instanceof MultiPolygon); } catch (IOException e) { assertFalse(e.getMessage(), true); } try { idObj = "Objet_434764"; eVecT1.geoType = "POLYGON"; eVecT1.topo = true; coordList = eVecT1.getRelation(idObj); assertTrue("Coordinate list should contains at least two edges in order to construct a polygon", coordList.size() > 1); geom = eVecT1.createGeometry(coordList, idObj); assertTrue("geom should be an instance of Polygon", geom instanceof Polygon); } catch (IOException e) { assertFalse(e.getMessage(), true); } }
protected Geometry createGeometry(List<Coordinate[]> coords, String FID) throws DataSourceException { GeometryFactory geomFact = new GeometryFactory(); Geometry geom = null; LinearRing shell = null; LinearRing[] holes = null; Polygon[] polys = null; if (geoType.equals(POINT)) { geom = (Geometry) geomFact.createPoint(coords.get(0)[0]); } else if (geoType.equals(LINESTRING)) { geom = (Geometry) geomFact.createLineString(coords.get(0)); } else if (geoType.equals(POLYGON) && !topo) { shell = geomFact.createLinearRing(coords.get(0)); if (coords.size()>1) { holes = new LinearRing[coords.size() - 1]; for (int i = 1; i < coords.size(); i++) { holes[i - 1] = geomFact.createLinearRing(coords.get(i)); } } geom = (Geometry) geomFact.createPolygon(shell, holes); } else if (geoType.equals(POLYGON) && topo) { List<Coordinate[]> polygonCoords = getPolygonCoordinates(coords); shell = geomFact.createLinearRing(polygonCoords.get(0)); holes = new LinearRing[polygonCoords.size() - 1]; for (int i = 1; i < polygonCoords.size(); i++) { holes[i - 1] = geomFact.createLinearRing(polygonCoords.get(i)); } geom = (Geometry) geomFact.createPolygon(shell, holes); } else if (geoType.equals(MULTIPOLYGON)) { polys = new Polygon[coords.size()]; Iterator<Coordinate[]> it = coords.iterator(); int cpt = 0; while (it.hasNext()) { shell = geomFact.createLinearRing(it.next()); polys[cpt] = geomFact.createPolygon(shell, holes); cpt++; } geom = geomFact.createMultiPolygon(polys); } else { if (logger.isLoggable(Level.SEVERE)) { logger.severe("Can't handle the type " + geoType + " for fid#" + FID); } throw new DataSourceException("Can't handle the type " + geoType + " for fid#" + FID); } return geom; }
EdigeoVEC { protected Geometry createGeometry(List<Coordinate[]> coords, String FID) throws DataSourceException { GeometryFactory geomFact = new GeometryFactory(); Geometry geom = null; LinearRing shell = null; LinearRing[] holes = null; Polygon[] polys = null; if (geoType.equals(POINT)) { geom = (Geometry) geomFact.createPoint(coords.get(0)[0]); } else if (geoType.equals(LINESTRING)) { geom = (Geometry) geomFact.createLineString(coords.get(0)); } else if (geoType.equals(POLYGON) && !topo) { shell = geomFact.createLinearRing(coords.get(0)); if (coords.size()>1) { holes = new LinearRing[coords.size() - 1]; for (int i = 1; i < coords.size(); i++) { holes[i - 1] = geomFact.createLinearRing(coords.get(i)); } } geom = (Geometry) geomFact.createPolygon(shell, holes); } else if (geoType.equals(POLYGON) && topo) { List<Coordinate[]> polygonCoords = getPolygonCoordinates(coords); shell = geomFact.createLinearRing(polygonCoords.get(0)); holes = new LinearRing[polygonCoords.size() - 1]; for (int i = 1; i < polygonCoords.size(); i++) { holes[i - 1] = geomFact.createLinearRing(polygonCoords.get(i)); } geom = (Geometry) geomFact.createPolygon(shell, holes); } else if (geoType.equals(MULTIPOLYGON)) { polys = new Polygon[coords.size()]; Iterator<Coordinate[]> it = coords.iterator(); int cpt = 0; while (it.hasNext()) { shell = geomFact.createLinearRing(it.next()); polys[cpt] = geomFact.createPolygon(shell, holes); cpt++; } geom = geomFact.createMultiPolygon(polys); } else { if (logger.isLoggable(Level.SEVERE)) { logger.severe("Can't handle the type " + geoType + " for fid#" + FID); } throw new DataSourceException("Can't handle the type " + geoType + " for fid#" + FID); } return geom; } }
EdigeoVEC { protected Geometry createGeometry(List<Coordinate[]> coords, String FID) throws DataSourceException { GeometryFactory geomFact = new GeometryFactory(); Geometry geom = null; LinearRing shell = null; LinearRing[] holes = null; Polygon[] polys = null; if (geoType.equals(POINT)) { geom = (Geometry) geomFact.createPoint(coords.get(0)[0]); } else if (geoType.equals(LINESTRING)) { geom = (Geometry) geomFact.createLineString(coords.get(0)); } else if (geoType.equals(POLYGON) && !topo) { shell = geomFact.createLinearRing(coords.get(0)); if (coords.size()>1) { holes = new LinearRing[coords.size() - 1]; for (int i = 1; i < coords.size(); i++) { holes[i - 1] = geomFact.createLinearRing(coords.get(i)); } } geom = (Geometry) geomFact.createPolygon(shell, holes); } else if (geoType.equals(POLYGON) && topo) { List<Coordinate[]> polygonCoords = getPolygonCoordinates(coords); shell = geomFact.createLinearRing(polygonCoords.get(0)); holes = new LinearRing[polygonCoords.size() - 1]; for (int i = 1; i < polygonCoords.size(); i++) { holes[i - 1] = geomFact.createLinearRing(polygonCoords.get(i)); } geom = (Geometry) geomFact.createPolygon(shell, holes); } else if (geoType.equals(MULTIPOLYGON)) { polys = new Polygon[coords.size()]; Iterator<Coordinate[]> it = coords.iterator(); int cpt = 0; while (it.hasNext()) { shell = geomFact.createLinearRing(it.next()); polys[cpt] = geomFact.createPolygon(shell, holes); cpt++; } geom = geomFact.createMultiPolygon(polys); } else { if (logger.isLoggable(Level.SEVERE)) { logger.severe("Can't handle the type " + geoType + " for fid#" + FID); } throw new DataSourceException("Can't handle the type " + geoType + " for fid#" + FID); } return geom; } EdigeoVEC(String path); }
EdigeoVEC { protected Geometry createGeometry(List<Coordinate[]> coords, String FID) throws DataSourceException { GeometryFactory geomFact = new GeometryFactory(); Geometry geom = null; LinearRing shell = null; LinearRing[] holes = null; Polygon[] polys = null; if (geoType.equals(POINT)) { geom = (Geometry) geomFact.createPoint(coords.get(0)[0]); } else if (geoType.equals(LINESTRING)) { geom = (Geometry) geomFact.createLineString(coords.get(0)); } else if (geoType.equals(POLYGON) && !topo) { shell = geomFact.createLinearRing(coords.get(0)); if (coords.size()>1) { holes = new LinearRing[coords.size() - 1]; for (int i = 1; i < coords.size(); i++) { holes[i - 1] = geomFact.createLinearRing(coords.get(i)); } } geom = (Geometry) geomFact.createPolygon(shell, holes); } else if (geoType.equals(POLYGON) && topo) { List<Coordinate[]> polygonCoords = getPolygonCoordinates(coords); shell = geomFact.createLinearRing(polygonCoords.get(0)); holes = new LinearRing[polygonCoords.size() - 1]; for (int i = 1; i < polygonCoords.size(); i++) { holes[i - 1] = geomFact.createLinearRing(polygonCoords.get(i)); } geom = (Geometry) geomFact.createPolygon(shell, holes); } else if (geoType.equals(MULTIPOLYGON)) { polys = new Polygon[coords.size()]; Iterator<Coordinate[]> it = coords.iterator(); int cpt = 0; while (it.hasNext()) { shell = geomFact.createLinearRing(it.next()); polys[cpt] = geomFact.createPolygon(shell, holes); cpt++; } geom = geomFact.createMultiPolygon(polys); } else { if (logger.isLoggable(Level.SEVERE)) { logger.severe("Can't handle the type " + geoType + " for fid#" + FID); } throw new DataSourceException("Can't handle the type " + geoType + " for fid#" + FID); } return geom; } EdigeoVEC(String path); void readVECFile(String obj, Visitor visitor); String getValue(String line, String target); }
EdigeoVEC { protected Geometry createGeometry(List<Coordinate[]> coords, String FID) throws DataSourceException { GeometryFactory geomFact = new GeometryFactory(); Geometry geom = null; LinearRing shell = null; LinearRing[] holes = null; Polygon[] polys = null; if (geoType.equals(POINT)) { geom = (Geometry) geomFact.createPoint(coords.get(0)[0]); } else if (geoType.equals(LINESTRING)) { geom = (Geometry) geomFact.createLineString(coords.get(0)); } else if (geoType.equals(POLYGON) && !topo) { shell = geomFact.createLinearRing(coords.get(0)); if (coords.size()>1) { holes = new LinearRing[coords.size() - 1]; for (int i = 1; i < coords.size(); i++) { holes[i - 1] = geomFact.createLinearRing(coords.get(i)); } } geom = (Geometry) geomFact.createPolygon(shell, holes); } else if (geoType.equals(POLYGON) && topo) { List<Coordinate[]> polygonCoords = getPolygonCoordinates(coords); shell = geomFact.createLinearRing(polygonCoords.get(0)); holes = new LinearRing[polygonCoords.size() - 1]; for (int i = 1; i < polygonCoords.size(); i++) { holes[i - 1] = geomFact.createLinearRing(polygonCoords.get(i)); } geom = (Geometry) geomFact.createPolygon(shell, holes); } else if (geoType.equals(MULTIPOLYGON)) { polys = new Polygon[coords.size()]; Iterator<Coordinate[]> it = coords.iterator(); int cpt = 0; while (it.hasNext()) { shell = geomFact.createLinearRing(it.next()); polys[cpt] = geomFact.createPolygon(shell, holes); cpt++; } geom = geomFact.createMultiPolygon(polys); } else { if (logger.isLoggable(Level.SEVERE)) { logger.severe("Can't handle the type " + geoType + " for fid#" + FID); } throw new DataSourceException("Can't handle the type " + geoType + " for fid#" + FID); } return geom; } EdigeoVEC(String path); void readVECFile(String obj, Visitor visitor); String getValue(String line, String target);  }