Search in sources :

Example 61 with LineString

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;
}
Also used : MultiCurveType(net.opengis.gml.v_3_2_1.MultiCurveType) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint)

Example 62 with LineString

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());
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) LineString(org.locationtech.jts.geom.LineString)

Example 63 with LineString

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());
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryCollection(org.locationtech.jts.geom.GeometryCollection) LineString(org.locationtech.jts.geom.LineString) Point(org.locationtech.jts.geom.Point) Polygon(org.locationtech.jts.geom.Polygon)

Example 64 with LineString

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);
}
Also used : ArcByPointsImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl) Arc(eu.esdihumboldt.util.geometry.interpolation.model.Arc) DefaultGeometryProperty(eu.esdihumboldt.hale.common.instance.geometry.DefaultGeometryProperty) LineString(org.locationtech.jts.geom.LineString) Coordinate(org.locationtech.jts.geom.Coordinate) GeometryNotSupportedException(eu.esdihumboldt.hale.io.gml.geometry.GeometryNotSupportedException) InterpolationAlgorithm(eu.esdihumboldt.util.geometry.interpolation.InterpolationAlgorithm)

Example 65 with LineString

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;
    }
}
Also used : GeometryProperty(eu.esdihumboldt.hale.common.schema.geometry.GeometryProperty) GeometryMetadata(eu.esdihumboldt.hale.common.schema.model.constraint.type.GeometryMetadata) QName(javax.xml.namespace.QName) GeoPackageDataType(mil.nga.geopackage.db.GeoPackageDataType) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint) DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) Geometry(org.locationtech.jts.geom.Geometry) FeatureColumn(mil.nga.geopackage.features.user.FeatureColumn) SpatialReferenceSystem(mil.nga.geopackage.core.srs.SpatialReferenceSystem)

Aggregations

LineString (org.locationtech.jts.geom.LineString)120 MultiLineString (org.locationtech.jts.geom.MultiLineString)48 Coordinate (org.locationtech.jts.geom.Coordinate)38 Geometry (org.locationtech.jts.geom.Geometry)35 Point (org.locationtech.jts.geom.Point)32 Test (org.junit.Test)24 Polygon (org.locationtech.jts.geom.Polygon)21 MultiPoint (org.locationtech.jts.geom.MultiPoint)19 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)14 WKTReader (org.locationtech.jts.io.WKTReader)13 ArrayList (java.util.ArrayList)12 CustomCoordinateSequence (org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence)12 HashMap (java.util.HashMap)10 DimensionInfo (org.apache.jena.geosparql.implementation.DimensionInfo)9 GeometryWrapper (org.apache.jena.geosparql.implementation.GeometryWrapper)9 ParseException (org.locationtech.jts.io.ParseException)9 DefaultGeometryProperty (eu.esdihumboldt.hale.common.instance.geometry.DefaultGeometryProperty)8 GeometryNotSupportedException (eu.esdihumboldt.hale.io.gml.geometry.GeometryNotSupportedException)7 MultiPolygon (org.locationtech.jts.geom.MultiPolygon)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)6