use of org.locationtech.jts.geom.LineString in project jena by apache.
the class GeometryReverseTest method testCheckLineString.
/**
* Test of check method, of class GeometryReverse.
*
* @throws org.opengis.util.FactoryException
*/
@Test
public void testCheckLineString() throws FactoryException {
WKTReader reader = new WKTReader();
try {
LineString geometry = (LineString) reader.read("LINESTRING(0 0, 2 0, 5 0)");
String srsURI = "http://www.opengis.net/def/crs/EPSG/0/4326";
Geometry expResult = reader.read("LINESTRING(0 0, 0 2, 0 5)");
Geometry result = GeometryReverse.check(geometry, srsURI);
//
//
assertEquals(expResult, result);
} catch (ParseException ex) {
System.err.println("ParseException: " + ex.getMessage());
}
}
use of org.locationtech.jts.geom.LineString in project jena by apache.
the class GeometryReverse method unpackLineStrings.
private static LineString[] unpackLineStrings(GeometryCollection geoCollection) {
GeometryFactory factory = geoCollection.getFactory();
int count = geoCollection.getNumGeometries();
LineString[] lineStrings = new LineString[count];
for (int i = 0; i < count; i++) {
Geometry geometry = geoCollection.getGeometryN(i);
Coordinate[] coordinates = getReversedCoordinates(geometry);
LineString lineString = factory.createLineString(coordinates);
lineStrings[i] = lineString;
}
return lineStrings;
}
use of org.locationtech.jts.geom.LineString in project jena by apache.
the class GeometryReverse method reversePolygon.
private static Polygon reversePolygon(Geometry geometry, GeometryFactory factory) {
Polygon finalGeometry;
Polygon polygon = (Polygon) geometry;
if (polygon.getNumInteriorRing() == 0) {
// There are no interior rings so perform the standard reversal.
Coordinate[] coordinates = getReversedCoordinates(geometry);
finalGeometry = factory.createPolygon(coordinates);
} else {
LineString exteriorRing = polygon.getExteriorRing();
Coordinate[] reversedExteriorCoordinates = getReversedCoordinates(exteriorRing);
LinearRing reversedExteriorRing = factory.createLinearRing(reversedExteriorCoordinates);
LinearRing[] reversedInteriorRings = new LinearRing[polygon.getNumInteriorRing()];
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
LineString interiorRing = polygon.getInteriorRingN(i);
Coordinate[] reversedInteriorCoordinates = getReversedCoordinates(interiorRing);
LinearRing reversedInteriorRing = factory.createLinearRing(reversedInteriorCoordinates);
reversedInteriorRings[i] = reversedInteriorRing;
}
finalGeometry = factory.createPolygon(reversedExteriorRing, reversedInteriorRings);
}
return finalGeometry;
}
use of org.locationtech.jts.geom.LineString in project yyl_example by Relucent.
the class JtsGeometryExample2 method disjointGeo.
/**
* 几何对象没有交点(相邻)
* @return 是否不相交
* @throws ParseException
*/
public static boolean disjointGeo() throws ParseException {
WKTReader reader = new WKTReader(GEOMETRY_FACTORY);
LineString geometry1 = (LineString) reader.read("LINESTRING(0 0, 2 0, 5 0)");
LineString geometry2 = (LineString) reader.read("LINESTRING(0 1, 0 2)");
return geometry1.disjoint(geometry2);
}
use of org.locationtech.jts.geom.LineString in project yyl_example by Relucent.
the class JtsGeometryExample1 method createGeoCollect.
/**
* create GeometryCollection contain point or multiPoint or line or multiLine or polygon or multiPolygon
* @return 图形集
* @throws ParseException
*/
public static GeometryCollection createGeoCollect() throws ParseException {
LineString line = createLine();
Polygon poly = createPolygonByWKT();
Geometry g1 = GEOMETRY_FACTORY.createGeometry(line);
Geometry g2 = GEOMETRY_FACTORY.createGeometry(poly);
Geometry[] garray = new Geometry[] { g1, g2 };
GeometryCollection gc = GEOMETRY_FACTORY.createGeometryCollection(garray);
return gc;
}
Aggregations