use of org.locationtech.jts.geom.LineString in project ddf by codice.
the class Wfs20JTStoGML321Converter method convertToMultiLineStringType.
// MultiLineStringType maps to MultiCurveType in opengis API
public static MultiCurveType convertToMultiLineStringType(MultiLineString multiLineString, String srsName) {
final MultiCurveType multiCurveType = GML320_OBJECT_FACTORY.createMultiCurveType();
for (int index = 0; index < multiLineString.getNumGeometries(); index++) {
final LineString lineString = (LineString) multiLineString.getGeometryN(index);
multiCurveType.getCurveMember().add(createCurvePropertyType(lineString));
}
multiCurveType.setSrsName(srsName);
return multiCurveType;
}
use of org.locationtech.jts.geom.LineString in project OpenCarto by jgaffuri.
the class GPSTraceDateStyle method draw.
@Override
public void draw(GPSTrace trace, int z, PointTransformation pt, Graphics2D gr) {
Geometry geom = trace.getGeom(z);
if (!(geom instanceof LineString))
return;
if (trace.getStartTime() == null)
gr.setColor(Color.gray);
else if (trace.getStartTime().getDate() == null)
gr.setColor(Color.gray);
else
gr.setColor(colScale.getColor(trace.getStartTime().getDate().getTime()));
gr.setStroke(stroke);
DrawingUtil.drawLine((LineString) geom, pt, gr, getxOffset(), getyOffset());
}
use of org.locationtech.jts.geom.LineString in project OpenCarto by jgaffuri.
the class BasicStyle method draw.
@Override
public void draw(MultiScaleFeature f, int z, PointTransformation pt, Graphics2D gr) {
Geometry geom = f.getGeom(z);
if (geom instanceof Point)
draw((Point) geom, pt, gr);
else if (geom instanceof LineString)
draw((LineString) geom, pt, gr);
else if (geom instanceof Polygon)
draw((Polygon) geom, pt, gr);
else if (geom instanceof GeometryCollection)
draw((GeometryCollection) geom, pt, gr);
else
logger.log(Level.WARNING, "Method not implemented yet for geometry type: " + geom.getClass().getSimpleName());
}
use of org.locationtech.jts.geom.LineString in project hale by halestudio.
the class ArcHandler method createGeometry.
@Override
public Object createGeometry(Instance instance, int srsDimension, IOProvider reader) throws GeometryNotSupportedException {
// read arc to LineString
@SuppressWarnings("unchecked") DefaultGeometryProperty<LineString> lineStringGeomProperty = (DefaultGeometryProperty<LineString>) super.createGeometry(instance, srsDimension, reader);
// create Arc
Coordinate[] coords = lineStringGeomProperty.getGeometry().getCoordinates();
if (coords.length != 3) {
throw new GeometryNotSupportedException("Arc must be defined by three points");
}
Arc arc = new ArcByPointsImpl(coords[0], coords[1], coords[2]);
// get interpolation algorithm
InterpolationAlgorithm interpol = InterpolationHelper.getInterpolation(reader, getGeometryFactory());
LineString interpolatedArc = interpol.interpolateArc(arc);
if (interpolatedArc == null) {
log.error("Arc could be not interpolated to Linestring");
return null;
}
return new DefaultGeometryProperty<LineString>(lineStringGeomProperty.getCRSDefinition(), interpolatedArc);
}
use of org.locationtech.jts.geom.LineString in project hale by halestudio.
the class GeopackageSchemaBuilder method getOrCreatePropertyType.
private TypeDefinition getOrCreatePropertyType(UserColumn column, GeometryColumns geomColumns, DefaultSchema schema) {
String localName;
if (column instanceof FeatureColumn && ((FeatureColumn) column).isGeometry()) {
localName = ((FeatureColumn) column).getGeometryType().getName();
} else {
localName = column.getDataType().name();
}
QName typeName = new QName(defaultNamespace, localName);
TypeDefinition type = schema.getType(typeName);
if (type != null) {
// use existing type
return type;
} else {
DefaultTypeDefinition typeDef = new DefaultTypeDefinition(typeName);
typeDef.setConstraint(MappingRelevantFlag.DISABLED);
typeDef.setConstraint(MappableFlag.DISABLED);
// simple type
typeDef.setConstraint(HasValueFlag.ENABLED);
if (column instanceof FeatureColumn && ((FeatureColumn) column).isGeometry()) {
mil.nga.sf.GeometryType geomType = ((FeatureColumn) column).getGeometryType();
typeDef.setConstraint(Binding.get(GeometryProperty.class));
Class<? extends Geometry> geomClass = Geometry.class;
switch(geomType) {
case LINESTRING:
geomClass = LineString.class;
break;
case MULTIPOINT:
geomClass = MultiPoint.class;
break;
case MULTILINESTRING:
geomClass = MultiLineString.class;
break;
case MULTIPOLYGON:
geomClass = MultiPolygon.class;
break;
case POINT:
geomClass = Point.class;
break;
case POLYGON:
geomClass = Polygon.class;
break;
default:
break;
}
typeDef.setConstraint(GeometryType.get(geomClass));
SpatialReferenceSystem srs = geomColumns.getSrs();
if (srs != null) {
String code = String.valueOf(srs.getOrganizationCoordsysId());
int dimension = GeometryMetadata.UNKNOWN_DIMENSION;
String srsText = srs.getDefinition();
String auth_name = srs.getOrganization();
typeDef.setConstraint(new GeometryMetadata(code, dimension, srsText, auth_name));
}
} else {
GeoPackageDataType dataType = column.getDataType();
Class<?> binding;
switch(dataType) {
case DATETIME:
binding = Instant.class;
break;
case DATE:
binding = LocalDate.class;
break;
default:
binding = dataType.getClassType();
}
typeDef.setConstraint(Binding.get(binding));
}
return typeDef;
}
}
Aggregations