Search in sources :

Example 1 with Point

use of org.geotoolkit.gml.xml.Point in project geotoolkit by Geomatys.

the class OMUtils method buildSamplingPoint.

public static SamplingFeature buildSamplingPoint(final String identifier, final double latitude, final double longitude) {
    final DirectPosition position = SOSXmlFactory.buildDirectPosition("2.0.0", "EPSG:4326", 2, Arrays.asList(latitude, longitude));
    final Point geom = SOSXmlFactory.buildPoint("2.0.0", "SamplingPoint", position);
    geom.setSrsName("EPSG:4326");
    final SamplingFeature sp = SOSXmlFactory.buildSamplingPoint("2.0.0", identifier, null, null, null, geom);
    return sp;
}
Also used : DirectPosition(org.opengis.geometry.DirectPosition) SamplingFeature(org.geotoolkit.sampling.xml.SamplingFeature) Point(org.geotoolkit.gml.xml.Point)

Example 2 with Point

use of org.geotoolkit.gml.xml.Point in project geotoolkit by Geomatys.

the class GeometryTransformer method getCoordinateDimension.

protected int getCoordinateDimension() {
    // The point dimension is equal to the number of dimensions in it.
    if (source instanceof Point) {
        Point pt = (Point) source;
        int dim = 0;
        if (pt.getCoordinates() != null)
            dim = pt.getCoordinates().getValues().size();
        else if (pt.getPos() != null) {
            dim = pt.getPos().getValue().size();
        }
        if (dim > 0)
            // otherwise, fallback on common analysis.
            return dim;
    }
    return familyTree().map(gt -> gt.source.getSrsDimension()).filter(dim -> dim != null && dim > 0).findFirst().orElseGet(() -> {
        LOGGER.fine("Arbitrary choice: GML geometry does not define any \"srsDimension\" attribute. Fallback on 2D.");
        return 2;
    });
}
Also used : Measure(org.apache.sis.internal.jaxb.gml.Measure) Unit(javax.measure.Unit) CRS(org.apache.sis.referencing.CRS) GeodeticCalculator(org.apache.sis.referencing.GeodeticCalculator) Spliterators(java.util.Spliterators) NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException) Coordinate(org.locationtech.jts.geom.Coordinate) MeasureType(org.geotoolkit.gml.xml.v321.MeasureType) PolygonPatchType(org.geotoolkit.gml.xml.v321.PolygonPatchType) Envelope(org.geotoolkit.gml.xml.Envelope) Matcher(java.util.regex.Matcher) SingleCRS(org.opengis.referencing.crs.SingleCRS) GeometryProperty(org.geotoolkit.gml.xml.GeometryProperty) Map(java.util.Map) Ring(org.geotoolkit.gml.xml.Ring) TransformException(org.opengis.referencing.operation.TransformException) MultiLineString(org.locationtech.jts.geom.MultiLineString) AxesConvention(org.apache.sis.referencing.cs.AxesConvention) AbstractCRS(org.apache.sis.referencing.crs.AbstractCRS) Logger(java.util.logging.Logger) MultiSurface(org.geotoolkit.gml.xml.MultiSurface) Objects(java.util.Objects) Cache(org.apache.sis.util.collection.Cache) List(java.util.List) Stream(java.util.stream.Stream) UnconvertibleObjectException(org.apache.sis.util.UnconvertibleObjectException) Polygon(org.locationtech.jts.geom.Polygon) Optional(java.util.Optional) Geometry(org.locationtech.jts.geom.Geometry) SurfaceType(org.geotoolkit.gml.xml.v321.SurfaceType) Pattern(java.util.regex.Pattern) Spliterator(java.util.Spliterator) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) FactoryException(org.opengis.util.FactoryException) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Coordinates(org.geotoolkit.gml.xml.Coordinates) PointProperty(org.geotoolkit.gml.xml.PointProperty) ArgumentChecks(org.apache.sis.util.ArgumentChecks) DoubleFunction(java.util.function.DoubleFunction) LinearRing(org.locationtech.jts.geom.LinearRing) HashMap(java.util.HashMap) DirectPositionList(org.geotoolkit.gml.xml.DirectPositionList) Function(java.util.function.Function) Supplier(java.util.function.Supplier) CurveProperty(org.geotoolkit.gml.xml.CurveProperty) MultiGeometry(org.geotoolkit.gml.xml.MultiGeometry) ArrayList(java.util.ArrayList) Angle(javax.measure.quantity.Angle) AbstractGeometry(org.geotoolkit.gml.xml.AbstractGeometry) Length(javax.measure.quantity.Length) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) AbstractCurveSegment(org.geotoolkit.gml.xml.AbstractCurveSegment) WithCoordinates(org.geotoolkit.gml.xml.WithCoordinates) AxisDirections(org.apache.sis.internal.referencing.AxisDirections) PointPropertyType(org.geotoolkit.gml.xml.v321.PointPropertyType) CurveSegmentArrayProperty(org.geotoolkit.gml.xml.CurveSegmentArrayProperty) StreamSupport(java.util.stream.StreamSupport) Point(org.geotoolkit.gml.xml.Point) NoSuchElementException(java.util.NoSuchElementException) DirectPosition(org.opengis.geometry.DirectPosition) Units(org.apache.sis.measure.Units) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Iterator(java.util.Iterator) PolygonProperty(org.geotoolkit.gml.xml.PolygonProperty) JTS(org.geotoolkit.geometry.jts.JTS) AbstractSurface(org.geotoolkit.gml.xml.AbstractSurface) Consumer(java.util.function.Consumer) MultiCurve(org.geotoolkit.gml.xml.MultiCurve) GeometryCollection(org.locationtech.jts.geom.GeometryCollection) LineString(org.locationtech.jts.geom.LineString) AbstractMap(java.util.AbstractMap) ArcByCenterPointType(org.geotoolkit.gml.xml.v321.ArcByCenterPointType) Curve(org.geotoolkit.gml.xml.Curve) AbstractRingProperty(org.geotoolkit.gml.xml.AbstractRingProperty) MultiPoint(org.locationtech.jts.geom.MultiPoint) SurfaceProperty(org.geotoolkit.gml.xml.SurfaceProperty) Collections(java.util.Collections) LineStringProperty(org.geotoolkit.gml.xml.LineStringProperty) AbstractRing(org.geotoolkit.gml.xml.AbstractRing) Point(org.geotoolkit.gml.xml.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint) Point(org.geotoolkit.gml.xml.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint)

Example 3 with Point

use of org.geotoolkit.gml.xml.Point in project geotoolkit by Geomatys.

the class GeometryTransformer method drawArc.

/**
 * Draw a succession of segments representing an arc or a circle.
 * @implNote
 * This method checks given angles to ensure that a full circle is drawn using
 * the strict necessary amount of points.
 *
 * @param center The center point of the arc to draw. The unit of measure MUST
 * be consistent with the unit of given radius.
 * @param radius The Radius of the arc to draw. Unit must be the same as the
 * one of input center point.
 * @param startAzimuth Start of the drawn line relative to the geographic north (clockwise order).
 * @param endAzimuth End of the drawn line relative to the geographic north (clockwise order). If
 * it's inferior to start angle, the arc is drawn on counter-clockwise order. If superior, the arc is
 * drawn on clockwise order.
 * @param angularStep The step to apply on the trigonometric circle to find
 * next point of the arc. its sign will be adapted to match draw order (clockwise
 * or counter clockwise).
 * @return An arc, as a discrete succession of points of configured precision.
 */
private static Coordinate[] drawArc(final DirectPosition center, final Measure radius, final Measure startAzimuth, final Measure endAzimuth, final Measure angularStep) throws TransformException {
    ArgumentChecks.ensureNonNull("Center point", center);
    final CoordinateReferenceSystem sourceCrs = center.getCoordinateReferenceSystem();
    ArgumentChecks.ensureNonNull("coordinate reference system", sourceCrs);
    final SingleCRS hCrs = CRS.getHorizontalComponent(sourceCrs);
    if (hCrs == null) {
        throw new UnconvertibleObjectException("Cannot extract geometries without projected part.");
    }
    final int xAxis = AxisDirections.indexOfColinear(sourceCrs.getCoordinateSystem(), hCrs.getCoordinateSystem());
    final int yAxis = xAxis + 1;
    final GeodeticCalculator gc = GeodeticCalculator.create(sourceCrs);
    gc.setStartPoint(center);
    final Unit<Length> radiusUnit = gc.getDistanceUnit();
    final double r = radius.getUnit(Length.class).getConverterTo(radiusUnit).convert(radius.value);
    double theta = startAzimuth.getUnit(Angle.class).getConverterTo(Units.DEGREE).convert(startAzimuth.value);
    double end = endAzimuth.getUnit(Angle.class).getConverterTo(Units.DEGREE).convert(endAzimuth.value);
    double phi = end - theta;
    // Draw a circle. We don"t bother preserving iteration order
    double positivePhi = Math.abs(phi);
    final boolean isCircle = positivePhi - 1e-8 <= 0 || positivePhi >= 360.0;
    if (isCircle) {
        phi = 360.0;
    }
    double step = (phi < 0 ? -1 : 1) * angularStep.getUnit(Angle.class).getConverterTo(Units.DEGREE).convert(angularStep.value);
    if ((phi / step) < 3) {
        step = phi / 3;
    }
    final Coordinate[] arcPerimeter = new Coordinate[(int) Math.ceil(phi / step) + 1];
    final DoubleFunction<Coordinate> pointOnCircle = azimuth -> {
        azimuth = ((azimuth + 180) % 360) - 180;
        gc.setStartingAzimuth(azimuth);
        gc.setGeodesicDistance(r);
        final DirectPosition pt = gc.getEndPoint();
        return new Coordinate(pt.getOrdinate(xAxis), pt.getOrdinate(yAxis));
    };
    /* Don't entirely fill array. Last point will be computed in a sepcial case,
         * to ensure it's closed properly if it's a circle.
         */
    for (int i = 0; i < arcPerimeter.length - 1; i++, theta += step) {
        arcPerimeter[i] = pointOnCircle.apply(theta);
    }
    if (isCircle) {
        // Ensure last point is the start point
        arcPerimeter[arcPerimeter.length - 1] = arcPerimeter[0];
    } else {
        arcPerimeter[arcPerimeter.length - 1] = pointOnCircle.apply(end);
    }
    return arcPerimeter;
}
Also used : SingleCRS(org.opengis.referencing.crs.SingleCRS) Measure(org.apache.sis.internal.jaxb.gml.Measure) Unit(javax.measure.Unit) CRS(org.apache.sis.referencing.CRS) GeodeticCalculator(org.apache.sis.referencing.GeodeticCalculator) Spliterators(java.util.Spliterators) NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException) Coordinate(org.locationtech.jts.geom.Coordinate) MeasureType(org.geotoolkit.gml.xml.v321.MeasureType) PolygonPatchType(org.geotoolkit.gml.xml.v321.PolygonPatchType) Envelope(org.geotoolkit.gml.xml.Envelope) Matcher(java.util.regex.Matcher) SingleCRS(org.opengis.referencing.crs.SingleCRS) GeometryProperty(org.geotoolkit.gml.xml.GeometryProperty) Map(java.util.Map) Ring(org.geotoolkit.gml.xml.Ring) TransformException(org.opengis.referencing.operation.TransformException) MultiLineString(org.locationtech.jts.geom.MultiLineString) AxesConvention(org.apache.sis.referencing.cs.AxesConvention) AbstractCRS(org.apache.sis.referencing.crs.AbstractCRS) Logger(java.util.logging.Logger) MultiSurface(org.geotoolkit.gml.xml.MultiSurface) Objects(java.util.Objects) Cache(org.apache.sis.util.collection.Cache) List(java.util.List) Stream(java.util.stream.Stream) UnconvertibleObjectException(org.apache.sis.util.UnconvertibleObjectException) Polygon(org.locationtech.jts.geom.Polygon) Optional(java.util.Optional) Geometry(org.locationtech.jts.geom.Geometry) SurfaceType(org.geotoolkit.gml.xml.v321.SurfaceType) Pattern(java.util.regex.Pattern) Spliterator(java.util.Spliterator) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) FactoryException(org.opengis.util.FactoryException) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Coordinates(org.geotoolkit.gml.xml.Coordinates) PointProperty(org.geotoolkit.gml.xml.PointProperty) ArgumentChecks(org.apache.sis.util.ArgumentChecks) DoubleFunction(java.util.function.DoubleFunction) LinearRing(org.locationtech.jts.geom.LinearRing) HashMap(java.util.HashMap) DirectPositionList(org.geotoolkit.gml.xml.DirectPositionList) Function(java.util.function.Function) Supplier(java.util.function.Supplier) CurveProperty(org.geotoolkit.gml.xml.CurveProperty) MultiGeometry(org.geotoolkit.gml.xml.MultiGeometry) ArrayList(java.util.ArrayList) Angle(javax.measure.quantity.Angle) AbstractGeometry(org.geotoolkit.gml.xml.AbstractGeometry) Length(javax.measure.quantity.Length) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) AbstractCurveSegment(org.geotoolkit.gml.xml.AbstractCurveSegment) WithCoordinates(org.geotoolkit.gml.xml.WithCoordinates) AxisDirections(org.apache.sis.internal.referencing.AxisDirections) PointPropertyType(org.geotoolkit.gml.xml.v321.PointPropertyType) CurveSegmentArrayProperty(org.geotoolkit.gml.xml.CurveSegmentArrayProperty) StreamSupport(java.util.stream.StreamSupport) Point(org.geotoolkit.gml.xml.Point) NoSuchElementException(java.util.NoSuchElementException) DirectPosition(org.opengis.geometry.DirectPosition) Units(org.apache.sis.measure.Units) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Iterator(java.util.Iterator) PolygonProperty(org.geotoolkit.gml.xml.PolygonProperty) JTS(org.geotoolkit.geometry.jts.JTS) AbstractSurface(org.geotoolkit.gml.xml.AbstractSurface) Consumer(java.util.function.Consumer) MultiCurve(org.geotoolkit.gml.xml.MultiCurve) GeometryCollection(org.locationtech.jts.geom.GeometryCollection) LineString(org.locationtech.jts.geom.LineString) AbstractMap(java.util.AbstractMap) ArcByCenterPointType(org.geotoolkit.gml.xml.v321.ArcByCenterPointType) Curve(org.geotoolkit.gml.xml.Curve) AbstractRingProperty(org.geotoolkit.gml.xml.AbstractRingProperty) MultiPoint(org.locationtech.jts.geom.MultiPoint) SurfaceProperty(org.geotoolkit.gml.xml.SurfaceProperty) Collections(java.util.Collections) LineStringProperty(org.geotoolkit.gml.xml.LineStringProperty) AbstractRing(org.geotoolkit.gml.xml.AbstractRing) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) DirectPosition(org.opengis.geometry.DirectPosition) Point(org.geotoolkit.gml.xml.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint) GeodeticCalculator(org.apache.sis.referencing.GeodeticCalculator) UnconvertibleObjectException(org.apache.sis.util.UnconvertibleObjectException) Angle(javax.measure.quantity.Angle) Length(javax.measure.quantity.Length) Coordinate(org.locationtech.jts.geom.Coordinate) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Example 4 with Point

use of org.geotoolkit.gml.xml.Point in project geotoolkit by Geomatys.

the class GeometryTransformer method getCoordinates.

/**
 * Check that given geometry is a primitive geometry (implements {@link WithCoordinates}), and
 * get its points.
 * @param source The geometry to extract points from.
 * @return Found points, never null, but can be empty.
 * @throws UnconvertibleObjectException If the given geometry does not implement {@link WithCoordinates}.
 */
private Spliterator<Coordinate> getCoordinates(final Object source) throws UnconvertibleObjectException {
    List<Double> values = null;
    if (source instanceof WithCoordinates) {
        final Coordinates coords = ((WithCoordinates) source).getCoordinates();
        if (coords != null) {
            /* HACK : In GML 3, coordinates are just a list of decimal values.
                 * The grouping by coordinate is done using "srsDimension" attribute
                 * on parent geometry type. However, with GML 2, there's another
                 * possibility : Coordinates use two distinct separators : one for
                 * decimal value separation, and another for coordinate separation.
                 * To manage both ways, we first check if coordinates object has
                 * succeeded in splitting underlying decimals in coordinates. If
                 * it does (return arrays with more than one element), we use
                 * that approach. Otherwise, we fallback on standard way which
                 * will try to determine manually the number of dimensions.
                 */
            Iterator<double[]> it = coords.points().iterator();
            if (it.hasNext() && it.next().length > 1) {
                return coords.points().map(GeometryTransformer::toCoordinate).spliterator();
            } else {
                values = coords.getValues();
            }
        } else if (source instanceof Point) {
            DirectPosition dp = ((Point) source).getPos();
            if (dp != null) {
                return Stream.of(convertDirectPosition(dp)).spliterator();
            } else
                // recognized object, but no value. Empty geometry
                return Spliterators.emptySpliterator();
        }
    }
    // TODO : below conditions should be removed when proper abstraction is setup on GML geometry definition.
    if (values == null) {
        final boolean isLineString = source instanceof org.geotoolkit.gml.xml.LineString;
        final boolean isLineStringSegment = source instanceof org.geotoolkit.gml.xml.LineStringSegment;
        if (isLineString || isLineStringSegment) {
            final DirectPositionList posList;
            if (isLineString) {
                posList = ((org.geotoolkit.gml.xml.LineString) source).getPosList();
            } else {
                posList = ((org.geotoolkit.gml.xml.LineStringSegment) source).getPosList();
            }
            if (posList != null) {
                values = posList.getValue();
            } else {
                final List<? extends DirectPosition> pList;
                if (isLineString) {
                    pList = ((org.geotoolkit.gml.xml.LineString) source).getPos();
                } else {
                    pList = ((org.geotoolkit.gml.xml.LineStringSegment) source).getPos();
                }
                if (pList != null) {
                    return pList.stream().map(GeometryTransformer::convertDirectPosition).filter(Objects::nonNull).spliterator();
                } else {
                    // We've identified a line, but there's no data in it
                    values = Collections.EMPTY_LIST;
                }
            }
        } else if (source instanceof org.geotoolkit.gml.xml.LinearRing) {
            // Note : do not check "getCoordinates", because it should have been done above.
            values = asDoubles(() -> ((org.geotoolkit.gml.xml.LinearRing) source).getPosList());
        } else if (source instanceof org.geotoolkit.gml.xml.v311.GeodesicStringType) {
            values = asDoubles(() -> ((org.geotoolkit.gml.xml.v311.GeodesicStringType) source).getPosList());
        } else if (source instanceof org.geotoolkit.gml.xml.v321.GeodesicStringType) {
            values = asDoubles(() -> ((org.geotoolkit.gml.xml.v321.GeodesicStringType) source).getPosList());
        } else if (source instanceof Curve) {
            CurveSegmentArrayProperty segments = ((Curve) source).getSegments();
            if (segments != null) {
                final List<? extends AbstractCurveSegment> curveSegments = segments.getAbstractCurveSegment();
                if (curveSegments != null) {
                    return curveSegments.stream().flatMap(seg -> StreamSupport.stream(getCoordinates(seg), false)).spliterator();
                }
            }
            // If we arrive here, we've got an empty curve.
            values = Collections.EMPTY_LIST;
        } else if (source instanceof ArcByCenterPointType) {
            final ArcByCenterPointType arc = (ArcByCenterPointType) source;
            org.opengis.geometry.DirectPosition dp = arc.getPos();
            if (dp == null) {
                PointPropertyType pp = arc.getPointProperty();
                if (pp == null) {
                    pp = arc.getPointRep();
                }
                if (pp == null) {
                    throw new UnconvertibleObjectException("Not enough information to build an arc.");
                }
                final Geometry point = new GeometryTransformer(pp.getPoint(), this).get();
                dp = JTS.toEnvelope(point).getLowerCorner();
            }
            CoordinateReferenceSystem crs = dp.getCoordinateReferenceSystem();
            if (crs == null) {
                crs = getSrsName().map(this::findCRS).orElseThrow(() -> new UnconvertibleObjectException("Cannot create an arc without its coordinate reference system"));
                final GeneralDirectPosition gdp = new GeneralDirectPosition(dp);
                gdp.setCoordinateReferenceSystem(crs);
                dp = gdp;
            }
            try {
                final Measure startAngle, endAngle;
                // If we miss a start or end angle, it means we're in presence of a circle.
                if (arc.getStartAngle() == null || arc.getEndAngle() == null) {
                    startAngle = new Measure(0, Units.DEGREE);
                    endAngle = new Measure(360, Units.DEGREE);
                } else {
                    startAngle = asMeasure(arc.getStartAngle());
                    endAngle = asMeasure(arc.getEndAngle());
                }
                final Coordinate[] coordinates = drawArc(dp, asMeasure(arc.getRadius()), startAngle, endAngle, ARC_PRECISION);
                return Spliterators.spliterator(coordinates, Spliterator.ORDERED);
            } catch (TransformException ex) {
                throw new UnconvertibleObjectException("Cannot draw an arc.", ex);
            }
        } else if (source instanceof org.geotoolkit.gml.xml.v311.ArcByCenterPointType) {
            // TODO : factorize with above case
            final org.geotoolkit.gml.xml.v311.ArcByCenterPointType arc = (org.geotoolkit.gml.xml.v311.ArcByCenterPointType) source;
            org.opengis.geometry.DirectPosition dp = arc.getPos();
            if (dp == null) {
                org.geotoolkit.gml.xml.v311.PointPropertyType pp = arc.getPointProperty();
                if (pp == null) {
                    pp = arc.getPointRep();
                }
                if (pp == null) {
                    throw new UnconvertibleObjectException("Not enough information to build an arc.");
                }
                final Geometry point = new GeometryTransformer(pp.getPoint(), this).get();
                dp = JTS.toEnvelope(point).getLowerCorner();
            }
            CoordinateReferenceSystem crs = dp.getCoordinateReferenceSystem();
            if (crs == null) {
                crs = getSrsName().map(this::findCRS).orElseThrow(() -> new UnconvertibleObjectException("Cannot create an arc without its coordinate reference system"));
                final GeneralDirectPosition gdp = new GeneralDirectPosition(dp);
                gdp.setCoordinateReferenceSystem(crs);
                dp = gdp;
            }
            try {
                final Measure startAngle, endAngle;
                // If we miss a start or end angle, it means we're in presence of a circle.
                if (arc.getStartAngle() == null || arc.getEndAngle() == null) {
                    startAngle = new Measure(0, Units.DEGREE);
                    endAngle = new Measure(360, Units.DEGREE);
                } else {
                    startAngle = asMeasure(arc.getStartAngle());
                    endAngle = asMeasure(arc.getEndAngle());
                }
                final Coordinate[] coordinates = drawArc(dp, asMeasure(arc.getRadius()), startAngle, endAngle, ARC_PRECISION);
                return Spliterators.spliterator(coordinates, Spliterator.ORDERED);
            } catch (TransformException ex) {
                throw new UnconvertibleObjectException("Cannot draw an arc.", ex);
            }
        }
    }
    if (values != null) {
        if (values.isEmpty()) {
            return Spliterators.emptySpliterator();
        }
        return new CoordinateSpliterator(values, getCoordinateDimension());
    }
    throw new UnconvertibleObjectException("Cannot extract coordinates from source geometry.");
}
Also used : Measure(org.apache.sis.internal.jaxb.gml.Measure) Unit(javax.measure.Unit) CRS(org.apache.sis.referencing.CRS) GeodeticCalculator(org.apache.sis.referencing.GeodeticCalculator) Spliterators(java.util.Spliterators) NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException) Coordinate(org.locationtech.jts.geom.Coordinate) MeasureType(org.geotoolkit.gml.xml.v321.MeasureType) PolygonPatchType(org.geotoolkit.gml.xml.v321.PolygonPatchType) Envelope(org.geotoolkit.gml.xml.Envelope) Matcher(java.util.regex.Matcher) SingleCRS(org.opengis.referencing.crs.SingleCRS) GeometryProperty(org.geotoolkit.gml.xml.GeometryProperty) Map(java.util.Map) Ring(org.geotoolkit.gml.xml.Ring) TransformException(org.opengis.referencing.operation.TransformException) MultiLineString(org.locationtech.jts.geom.MultiLineString) AxesConvention(org.apache.sis.referencing.cs.AxesConvention) AbstractCRS(org.apache.sis.referencing.crs.AbstractCRS) Logger(java.util.logging.Logger) MultiSurface(org.geotoolkit.gml.xml.MultiSurface) Objects(java.util.Objects) Cache(org.apache.sis.util.collection.Cache) List(java.util.List) Stream(java.util.stream.Stream) UnconvertibleObjectException(org.apache.sis.util.UnconvertibleObjectException) Polygon(org.locationtech.jts.geom.Polygon) Optional(java.util.Optional) Geometry(org.locationtech.jts.geom.Geometry) SurfaceType(org.geotoolkit.gml.xml.v321.SurfaceType) Pattern(java.util.regex.Pattern) Spliterator(java.util.Spliterator) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) FactoryException(org.opengis.util.FactoryException) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Coordinates(org.geotoolkit.gml.xml.Coordinates) PointProperty(org.geotoolkit.gml.xml.PointProperty) ArgumentChecks(org.apache.sis.util.ArgumentChecks) DoubleFunction(java.util.function.DoubleFunction) LinearRing(org.locationtech.jts.geom.LinearRing) HashMap(java.util.HashMap) DirectPositionList(org.geotoolkit.gml.xml.DirectPositionList) Function(java.util.function.Function) Supplier(java.util.function.Supplier) CurveProperty(org.geotoolkit.gml.xml.CurveProperty) MultiGeometry(org.geotoolkit.gml.xml.MultiGeometry) ArrayList(java.util.ArrayList) Angle(javax.measure.quantity.Angle) AbstractGeometry(org.geotoolkit.gml.xml.AbstractGeometry) Length(javax.measure.quantity.Length) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) AbstractCurveSegment(org.geotoolkit.gml.xml.AbstractCurveSegment) WithCoordinates(org.geotoolkit.gml.xml.WithCoordinates) AxisDirections(org.apache.sis.internal.referencing.AxisDirections) PointPropertyType(org.geotoolkit.gml.xml.v321.PointPropertyType) CurveSegmentArrayProperty(org.geotoolkit.gml.xml.CurveSegmentArrayProperty) StreamSupport(java.util.stream.StreamSupport) Point(org.geotoolkit.gml.xml.Point) NoSuchElementException(java.util.NoSuchElementException) DirectPosition(org.opengis.geometry.DirectPosition) Units(org.apache.sis.measure.Units) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Iterator(java.util.Iterator) PolygonProperty(org.geotoolkit.gml.xml.PolygonProperty) JTS(org.geotoolkit.geometry.jts.JTS) AbstractSurface(org.geotoolkit.gml.xml.AbstractSurface) Consumer(java.util.function.Consumer) MultiCurve(org.geotoolkit.gml.xml.MultiCurve) GeometryCollection(org.locationtech.jts.geom.GeometryCollection) LineString(org.locationtech.jts.geom.LineString) AbstractMap(java.util.AbstractMap) ArcByCenterPointType(org.geotoolkit.gml.xml.v321.ArcByCenterPointType) Curve(org.geotoolkit.gml.xml.Curve) AbstractRingProperty(org.geotoolkit.gml.xml.AbstractRingProperty) MultiPoint(org.locationtech.jts.geom.MultiPoint) SurfaceProperty(org.geotoolkit.gml.xml.SurfaceProperty) Collections(java.util.Collections) LineStringProperty(org.geotoolkit.gml.xml.LineStringProperty) AbstractRing(org.geotoolkit.gml.xml.AbstractRing) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) DirectPosition(org.opengis.geometry.DirectPosition) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) CurveSegmentArrayProperty(org.geotoolkit.gml.xml.CurveSegmentArrayProperty) UnconvertibleObjectException(org.apache.sis.util.UnconvertibleObjectException) ArcByCenterPointType(org.geotoolkit.gml.xml.v321.ArcByCenterPointType) Measure(org.apache.sis.internal.jaxb.gml.Measure) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) DirectPosition(org.opengis.geometry.DirectPosition) Coordinates(org.geotoolkit.gml.xml.Coordinates) WithCoordinates(org.geotoolkit.gml.xml.WithCoordinates) MultiCurve(org.geotoolkit.gml.xml.MultiCurve) Curve(org.geotoolkit.gml.xml.Curve) TransformException(org.opengis.referencing.operation.TransformException) Point(org.geotoolkit.gml.xml.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint) Geometry(org.locationtech.jts.geom.Geometry) MultiGeometry(org.geotoolkit.gml.xml.MultiGeometry) AbstractGeometry(org.geotoolkit.gml.xml.AbstractGeometry) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) DirectPositionList(org.geotoolkit.gml.xml.DirectPositionList) Coordinate(org.locationtech.jts.geom.Coordinate) WithCoordinates(org.geotoolkit.gml.xml.WithCoordinates) PointPropertyType(org.geotoolkit.gml.xml.v321.PointPropertyType)

Example 5 with Point

use of org.geotoolkit.gml.xml.Point in project geotoolkit by Geomatys.

the class AbstractFeatureType method extendBoundingShape.

public void extendBoundingShape(AbstractGeometry newGeom) {
    if (newGeom == null) {
        return;
    }
    // for now, only point are handled
    if (newGeom instanceof Point) {
        Point pt = (Point) newGeom;
        if (boundedBy != null && boundedBy.getEnvelope() != null) {
            final GeneralEnvelope gEnv = new GeneralEnvelope(boundedBy.getEnvelope());
            gEnv.add(pt.getPos());
            boundedBy = new BoundingShapeType(gEnv);
        } else {
            final GeneralEnvelope gEnv = new GeneralEnvelope(pt.getCoordinateReferenceSystem(true));
            gEnv.setRange(0, pt.getPos().getOrdinate(1), pt.getPos().getOrdinate(1));
            gEnv.setRange(1, pt.getPos().getOrdinate(0), pt.getPos().getOrdinate(0));
            boundedBy = new BoundingShapeType(gEnv);
        }
    } else {
        throw new UnsupportedOperationException("extendBoundingShape is only supported for Point");
    }
}
Also used : Point(org.geotoolkit.gml.xml.Point) GeneralEnvelope(org.apache.sis.geometry.GeneralEnvelope)

Aggregations

Point (org.geotoolkit.gml.xml.Point)6 DirectPosition (org.opengis.geometry.DirectPosition)4 AbstractMap (java.util.AbstractMap)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 Iterator (java.util.Iterator)3 List (java.util.List)3 Map (java.util.Map)3 NoSuchElementException (java.util.NoSuchElementException)3 Objects (java.util.Objects)3 Optional (java.util.Optional)3 Spliterator (java.util.Spliterator)3 Spliterators (java.util.Spliterators)3 Consumer (java.util.function.Consumer)3 DoubleFunction (java.util.function.DoubleFunction)3 Function (java.util.function.Function)3 Supplier (java.util.function.Supplier)3 Logger (java.util.logging.Logger)3 Matcher (java.util.regex.Matcher)3