use of org.geotools.geometry.iso.primitive.CurveImpl in project sldeditor by robward-scisys.
the class WKTConversion method parseWKTString.
/**
* Parses the wkt string.
*
* @param wktString the wkt string
* @return the WKT geometry
*/
public static WKTGeometry parseWKTString(String wktString) {
if (wktParser == null) {
initialise();
}
if (wktString == null) {
return null;
}
WKTGeometry wktGeometry = new WKTGeometry();
// Remove wkt:// prefix
if (wktString.startsWith(WKT_PREFIX)) {
wktString = wktString.substring(WKT_PREFIX.length());
}
try {
org.opengis.geometry.Geometry geometry = wktParser.parse(wktString);
if (geometry instanceof MultiPrimitiveImpl) {
MultiPrimitiveImpl multiLine = (MultiPrimitiveImpl) geometry;
parseWKTMultiPrimitive(wktGeometry, multiLine);
} else if (geometry instanceof PointImpl) {
parseWKTPoint(wktGeometry, geometry);
} else if (geometry instanceof CurveImpl) {
parseWKTCurve(wktGeometry, geometry);
} else if (geometry instanceof SurfaceImpl) {
parseWKTSurface(wktGeometry, geometry);
}
} catch (ParseException e) {
wktGeometry.setValid(false);
for (WKTType wktType : wktTypeList) {
if (wktString.startsWith(wktType.getName())) {
wktGeometry.setGeometryType(wktType);
}
}
} catch (IllegalArgumentException e) {
ConsoleManager.getInstance().error(WKTConversion.class, e.getLocalizedMessage());
}
return wktGeometry;
}
use of org.geotools.geometry.iso.primitive.CurveImpl in project sldeditor by robward-scisys.
the class WKTConversion method parseWKTSurface.
/**
* Parses the WKT surface.
*
* @param wktGeometry the wkt geometry
* @param geometry the geometry
*/
private static void parseWKTSurface(WKTGeometry wktGeometry, org.opengis.geometry.Geometry geometry) {
wktGeometry.setGeometryType(getWKTType(WKT_POLYGON));
SurfaceImpl surfaceImpl = (SurfaceImpl) geometry;
for (Ring ring : surfaceImpl.getBoundaryRings()) {
WKTSegmentList ptList = new WKTSegmentList();
wktGeometry.addSegmentList(0, ptList);
for (Primitive primitive : ring.getElements()) {
if (primitive instanceof CurveImpl) {
CurveImpl curve = (CurveImpl) primitive;
extractLineSegments(curve, ptList);
}
}
}
}
use of org.geotools.geometry.iso.primitive.CurveImpl in project sldeditor by robward-scisys.
the class WKTConversion method parseWKTMultiSurface.
/**
* Parses the WKT multi surface.
*
* @param wktGeometry the wkt geometry
* @param index the index
* @param primitive the primitive
*/
private static void parseWKTMultiSurface(WKTGeometry wktGeometry, int index, Primitive primitive) {
wktGeometry.setGeometryType(getWKTType(WKT_MULTIPOLYGON));
SurfaceImpl surfaceImpl = (SurfaceImpl) primitive;
for (Ring ring : surfaceImpl.getBoundaryRings()) {
WKTSegmentList ptList = new WKTSegmentList();
for (Primitive ringPrimitive : ring.getElements()) {
if (ringPrimitive instanceof CurveImpl) {
CurveImpl curve = (CurveImpl) ringPrimitive;
extractLineSegments(curve, ptList);
}
}
wktGeometry.addSegmentList(index, ptList);
}
}
use of org.geotools.geometry.iso.primitive.CurveImpl in project sldeditor by robward-scisys.
the class WKTConversion method parseWKTMultiCurve.
/**
* Parses the WKT multi curve.
*
* @param wktGeometry the wkt geometry
* @param index the index
* @param primitive the primitive
*/
private static void parseWKTMultiCurve(WKTGeometry wktGeometry, int index, Primitive primitive) {
WKTSegmentList ptList = new WKTSegmentList();
wktGeometry.setGeometryType(getWKTType(WKT_MULTILINESTRING));
CurveImpl curve = (CurveImpl) primitive;
extractLineSegments(curve, ptList);
wktGeometry.addSegmentList(index, ptList);
}
use of org.geotools.geometry.iso.primitive.CurveImpl in project sldeditor by robward-scisys.
the class WKTConversion method parseWKTCurve.
/**
* Parses the WKT curve.
*
* @param wktGeometry the wkt geometry
* @param geometry the geometry
*/
private static void parseWKTCurve(WKTGeometry wktGeometry, org.opengis.geometry.Geometry geometry) {
wktGeometry.setGeometryType(getWKTType(WKT_LINESTRING));
CurveImpl curveImpl = (CurveImpl) geometry;
WKTSegmentList ptList = new WKTSegmentList();
wktGeometry.addSegmentList(0, ptList);
extractLineSegments(curveImpl, ptList);
}
Aggregations