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 arctic-sea by 52North.
the class GeoJSONDecoder method decodeMultiLineString.
protected MultiLineString decodeMultiLineString(JsonNode node, GeometryFactory fac) throws GeoJSONDecodingException {
JsonNode coordinates = requireCoordinates(node);
LineString[] lineStrings = new LineString[coordinates.size()];
for (int i = 0; i < coordinates.size(); ++i) {
JsonNode coords = coordinates.get(i);
lineStrings[i] = fac.createLineString(decodeCoordinates(coords));
}
return fac.createMultiLineString(lineStrings);
}
use of org.locationtech.jts.geom.LineString in project arctic-sea by 52North.
the class ProfileObservation method setFeatureGeometry.
private void setFeatureGeometry(List<Coordinate> coordinates, int srid) {
AbstractFeature featureOfInterest = getObservationConstellation().getFeatureOfInterest();
if (featureOfInterest instanceof AbstractSamplingFeature) {
AbstractSamplingFeature sf = (AbstractSamplingFeature) featureOfInterest;
Coordinate[] coords = coordinates.toArray(new Coordinate[0]);
try {
LineString lineString = new GeometryFactory().createLineString(coords);
lineString.setSRID(srid);
sf.setGeometry(lineString);
sf.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_CURVE);
} catch (InvalidSridException e) {
// TODO
}
}
}
use of org.locationtech.jts.geom.LineString in project arctic-sea by 52North.
the class TrajectoryObservation method checkForFeature.
/**
* Create geometry for featureOfInterest from
* {@link TimeLocationValueTriple}s
*
* @param values
* The {@link TimeLocationValueTriple}s to check for
* featureOfInterest
*/
private void checkForFeature(List<TimeLocationValueTriple> values) {
AbstractFeature featureOfInterest = getObservationConstellation().getFeatureOfInterest();
if (featureOfInterest instanceof AbstractSamplingFeature) {
AbstractSamplingFeature sf = (AbstractSamplingFeature) featureOfInterest;
Coordinate[] coords = getCoordinates(values);
int srid = 0;
if (sf.isSetGeometry()) {
srid = sf.getGeometry().getSRID();
coords = (Coordinate[]) ArrayUtils.addAll(sf.getGeometry().getCoordinates(), coords);
} else {
TimeLocationValueTriple next = values.iterator().next();
if (next.isSetLocation()) {
srid = next.getLocation().getSRID();
}
}
try {
if (coords.length == 1) {
Point point = new GeometryFactory().createPoint(coords[0]);
point.setSRID(srid);
sf.setGeometry(point);
} else if (coords.length > 1) {
LineString lineString = new GeometryFactory().createLineString(coords);
lineString.setSRID(srid);
sf.setGeometry(lineString);
}
} catch (InvalidSridException e) {
// TODO
}
}
}
Aggregations