use of org.locationtech.jts.geom.LineString in project arctic-sea by 52North.
the class GmlEncoderv321 method createLineStringFromJtsGeometry.
/**
* Creates a XML LineString from a SOS LineString.
*
* @param jtsLineString
* SOS LineString
* @param xbLst
* XML LinetSring
*/
private void createLineStringFromJtsGeometry(LineString jtsLineString, LineStringType xbLst) {
String srsName = getSrsName(jtsLineString);
xbLst.setSrsName(srsName);
DirectPositionListType xbPosList = xbLst.addNewPosList();
xbPosList.setSrsName(srsName);
xbPosList.setStringValue(JTSHelper.getCoordinatesString(jtsLineString));
}
use of org.locationtech.jts.geom.LineString in project arctic-sea by 52North.
the class SamplingEncoderv100 method createFeature.
private XmlObject createFeature(AbstractFeature absFeature) throws EncodingException {
if (absFeature instanceof AbstractSamplingFeature) {
AbstractSamplingFeature sampFeat = (AbstractSamplingFeature) absFeature;
if (sampFeat.getFeatureType().equals(SfConstants.FT_SAMPLINGPOINT) || sampFeat.getFeatureType().equals(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_POINT) || sampFeat.getGeometry() instanceof Point) {
SamplingPointDocument xbSamplingPointDoc = SamplingPointDocument.Factory.newInstance(getXmlOptions());
SamplingPointType xbSamplingPoint = xbSamplingPointDoc.addNewSamplingPoint();
addValuesToFeature(xbSamplingPoint, sampFeat);
XmlObject xbGeomety = getEncodedGeometry(sampFeat.getGeometry(), absFeature.getGmlId());
xbSamplingPoint.addNewPosition().addNewPoint().set(xbGeomety);
sampFeat.wasEncoded();
return xbSamplingPointDoc;
} else if (sampFeat.getFeatureType().equals(SfConstants.FT_SAMPLINGCURVE) || sampFeat.getFeatureType().equals(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_CURVE) || sampFeat.getGeometry() instanceof LineString) {
SamplingCurveDocument xbSamplingCurveDoc = SamplingCurveDocument.Factory.newInstance(getXmlOptions());
SamplingCurveType xbSamplingCurve = xbSamplingCurveDoc.addNewSamplingCurve();
addValuesToFeature(xbSamplingCurve, sampFeat);
XmlObject xbGeomety = getEncodedGeometry(sampFeat.getGeometry(), absFeature.getGmlId());
xbSamplingCurve.addNewShape().addNewCurve().set(xbGeomety);
sampFeat.wasEncoded();
return xbSamplingCurveDoc;
} else if (sampFeat.getFeatureType().equals(SfConstants.FT_SAMPLINGSURFACE) || sampFeat.getFeatureType().equals(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_SURFACE) || sampFeat.getGeometry() instanceof Polygon) {
SamplingSurfaceDocument xbSamplingSurfaceDoc = SamplingSurfaceDocument.Factory.newInstance(getXmlOptions());
SamplingSurfaceType xbSamplingSurface = xbSamplingSurfaceDoc.addNewSamplingSurface();
addValuesToFeature(xbSamplingSurface, sampFeat);
XmlObject xbGeomety = getEncodedGeometry(sampFeat.getGeometry(), absFeature.getGmlId());
xbSamplingSurface.addNewShape().addNewSurface().set(xbGeomety);
sampFeat.wasEncoded();
return xbSamplingSurfaceDoc;
}
} else if (absFeature instanceof FeatureCollection) {
createFeatureCollection((FeatureCollection) absFeature);
}
throw new UnsupportedEncoderInputException(this, absFeature);
}
use of org.locationtech.jts.geom.LineString in project presto by prestodb.
the class GeoFunctions method stInteriorRings.
@SqlNullable
@Description("Returns an array of interior rings of a polygon")
@ScalarFunction("ST_InteriorRings")
@SqlType("array(" + GEOMETRY_TYPE_NAME + ")")
public static Block stInteriorRings(@SqlType(GEOMETRY_TYPE_NAME) Slice input) {
Geometry geometry = deserialize(input);
validateType("ST_InteriorRings", geometry, EnumSet.of(POLYGON));
if (geometry.isEmpty()) {
return null;
}
org.locationtech.jts.geom.Polygon polygon = (org.locationtech.jts.geom.Polygon) geometry;
BlockBuilder blockBuilder = GEOMETRY.createBlockBuilder(null, polygon.getNumInteriorRing());
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
GEOMETRY.writeSlice(blockBuilder, serialize((LineString) polygon.getInteriorRingN(i)));
}
return blockBuilder.build();
}
use of org.locationtech.jts.geom.LineString in project yyl_example by Relucent.
the class JtsGeometryExample1 method createLineByWKT.
/**
* create a line by WKT
* @return 线
* @throws ParseException
*/
public static LineString createLineByWKT() throws ParseException {
WKTReader reader = new WKTReader(GEOMETRY_FACTORY);
LineString line = (LineString) reader.read("LINESTRING(0 0, 2 0)");
return line;
}
use of org.locationtech.jts.geom.LineString in project yyl_example by Relucent.
the class JtsGeometryExample2 method intersectsGeo.
/**
* 至少一个公共点(相交)
* @return 是否相交
* @throws ParseException
*/
public static boolean intersectsGeo() 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 0, 0 2)");
// 相交点
Geometry interPoint = geometry1.intersection(geometry2);
// 输出 POINT (0 0)
System.out.println(interPoint.toText());
return geometry1.intersects(geometry2);
}
Aggregations