use of org.geotoolkit.kml.xml.v220.AbstractGeometryType in project geotoolkit by Geomatys.
the class ShapeType method equals.
/**
* Verify if this entry is identical to specified object.
*/
@Override
public boolean equals(final Object object) {
if (object == this) {
return true;
}
if (object instanceof ShapeType) {
final ShapeType that = (ShapeType) object;
AbstractGeometryType thatgeom = null;
if (that.abstractGeometry != null) {
thatgeom = that.abstractGeometry.getValue();
}
AbstractGeometryType thisgeom = null;
if (this.abstractGeometry != null) {
thisgeom = this.abstractGeometry.getValue();
}
return Objects.equals(thisgeom, thatgeom) && Objects.equals(this.actuate, that.actuate) && Objects.equals(this.href, that.href) && Objects.equals(this.remoteSchema, that.remoteSchema) && Objects.equals(this.role, that.role) && Objects.equals(this.show, that.show) && Objects.equals(this.nilReason, that.nilReason) && Objects.equals(this.type, that.type) && Objects.equals(this.arcrole, that.arcrole);
}
return false;
}
use of org.geotoolkit.kml.xml.v220.AbstractGeometryType in project geotoolkit by Geomatys.
the class OGC110toGTTransformer method visitSpatialOp.
/**
* Transform a SLD spatial Filter v1.1 in GT filter.
*/
public Filter visitSpatialOp(final JAXBElement<? extends org.geotoolkit.ogc.xml.v110.SpatialOpsType> jax) throws NoSuchAuthorityCodeException, FactoryException {
final org.geotoolkit.ogc.xml.v110.SpatialOpsType ops = jax.getValue();
final String OpName = jax.getName().getLocalPart();
if (ops instanceof org.geotoolkit.ogc.xml.v110.BinarySpatialOpType) {
final org.geotoolkit.ogc.xml.v110.BinarySpatialOpType binary = (org.geotoolkit.ogc.xml.v110.BinarySpatialOpType) ops;
final JAXBElement<? extends AbstractGeometryType> geom = binary.getAbstractGeometry();
final JAXBElement<EnvelopeType> env = binary.getEnvelope();
final org.geotoolkit.ogc.xml.v110.PropertyNameType pnt = binary.getPropertyName().getValue();
final Expression left = visitPropertyName(pnt);
final Expression right;
if (env != null && env.getValue() != null) {
try {
right = visitEnv(env);
} catch (FactoryException ex) {
throw new IllegalArgumentException("SRS name is unknowned : " + ex.getLocalizedMessage(), ex);
}
} else {
right = visit(geom);
}
if (OGCJAXBStatics.FILTER_SPATIAL_CONTAINS.equalsIgnoreCase(OpName)) {
return filterFactory.contains(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_CROSSES.equalsIgnoreCase(OpName)) {
return filterFactory.crosses(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_DISJOINT.equalsIgnoreCase(OpName)) {
return filterFactory.disjoint(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_EQUALS.equalsIgnoreCase(OpName)) {
return filterFactory.equals(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_INTERSECTS.equalsIgnoreCase(OpName)) {
return filterFactory.intersects(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_OVERLAPS.equalsIgnoreCase(OpName)) {
return filterFactory.overlaps(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_TOUCHES.equalsIgnoreCase(OpName)) {
return filterFactory.touches(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_WITHIN.equalsIgnoreCase(OpName)) {
return filterFactory.within(left, right);
}
throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
} else if (ops instanceof org.geotoolkit.ogc.xml.v110.DistanceBufferType) {
final org.geotoolkit.ogc.xml.v110.DistanceBufferType dstOp = (org.geotoolkit.ogc.xml.v110.DistanceBufferType) ops;
final org.geotoolkit.ogc.xml.v110.DistanceType dt = dstOp.getDistanceType();
final JAXBElement<? extends AbstractGeometryType> geom = dstOp.getAbstractGeometry();
final org.geotoolkit.ogc.xml.v110.PropertyNameType pnt = dstOp.getPropertyName();
final Expression geom1 = visitPropertyName(pnt);
final Expression geom2 = visit(geom);
// TODO marche pas ? ou est la distance ? Double.valueOf(dt.getContent());
final double distance = 0;
final String units = dt.getUnits();
if (OGCJAXBStatics.FILTER_SPATIAL_DWITHIN.equalsIgnoreCase(OpName)) {
return filterFactory.dwithin(geom1, geom2, distance, units);
} else if (OGCJAXBStatics.FILTER_SPATIAL_BEYOND.equalsIgnoreCase(OpName)) {
return filterFactory.beyond(geom1, geom2, distance, units);
}
throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
} else if (ops instanceof org.geotoolkit.ogc.xml.v110.BBOXType) {
final org.geotoolkit.ogc.xml.v110.BBOXType binary = (org.geotoolkit.ogc.xml.v110.BBOXType) ops;
final EnvelopeType box = binary.getEnvelope();
final String pnt = binary.getPropertyName();
final Expression geom;
if (pnt != null) {
geom = visitPropertyName(pnt);
} else {
geom = null;
}
final double minx = box.getLowerCorner().getOrdinate(0);
final double maxx = box.getUpperCorner().getOrdinate(0);
final double miny = box.getLowerCorner().getOrdinate(1);
final double maxy = box.getUpperCorner().getOrdinate(1);
// final double minx = box.getPos().get(0).getOrdinate(0);
// final double maxx = box.getPos().get(0).getOrdinate(1);
// final double miny = box.getPos().get(1).getOrdinate(0);
// final double maxy = box.getPos().get(1).getOrdinate(1);
final String srs = box.getSrsName();
if (OGCJAXBStatics.FILTER_SPATIAL_BBOX.equalsIgnoreCase(OpName)) {
return filterFactory.bbox(geom, minx, miny, maxx, maxy, srs);
}
throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
}
throw new IllegalArgumentException("Unknowed filter element" + jax);
}
use of org.geotoolkit.kml.xml.v220.AbstractGeometryType in project geotoolkit by Geomatys.
the class OGC200toGTTransformer method visitSpatialOp.
/**
* Transform a SLD spatial Filter v1.1 in GT filter.
*/
public Filter visitSpatialOp(final JAXBElement<? extends org.geotoolkit.ogc.xml.v200.SpatialOpsType> jax) throws NoSuchAuthorityCodeException, FactoryException {
final org.geotoolkit.ogc.xml.v200.SpatialOpsType ops = jax.getValue();
final String OpName = jax.getName().getLocalPart();
if (ops instanceof org.geotoolkit.ogc.xml.v200.BinarySpatialOpType) {
final org.geotoolkit.ogc.xml.v200.BinarySpatialOpType binary = (org.geotoolkit.ogc.xml.v200.BinarySpatialOpType) ops;
Object geom = binary.getAny();
if (geom instanceof JAXBElement) {
geom = ((JAXBElement) geom).getValue();
}
final Expression left = visitPropertyName(binary.getValueReference());
final Expression right;
if (geom instanceof EnvelopeType) {
try {
right = visitEnv((EnvelopeType) geom);
} catch (FactoryException ex) {
throw new IllegalArgumentException("SRS name is unknowned : " + ex.getLocalizedMessage(), ex);
}
} else if (geom instanceof AbstractGeometryType) {
right = visit((AbstractGeometryType) geom);
} else {
throw new IllegalArgumentException("Unexpected geometry type:" + geom);
}
if (OGCJAXBStatics.FILTER_SPATIAL_CONTAINS.equalsIgnoreCase(OpName)) {
return filterFactory.contains(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_CROSSES.equalsIgnoreCase(OpName)) {
return filterFactory.crosses(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_DISJOINT.equalsIgnoreCase(OpName)) {
return filterFactory.disjoint(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_EQUALS.equalsIgnoreCase(OpName)) {
return filterFactory.equals(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_INTERSECTS.equalsIgnoreCase(OpName)) {
return filterFactory.intersects(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_OVERLAPS.equalsIgnoreCase(OpName)) {
return filterFactory.overlaps(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_TOUCHES.equalsIgnoreCase(OpName)) {
return filterFactory.touches(left, right);
} else if (OGCJAXBStatics.FILTER_SPATIAL_WITHIN.equalsIgnoreCase(OpName)) {
return filterFactory.within(left, right);
}
throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
} else if (ops instanceof org.geotoolkit.ogc.xml.v200.DistanceBufferType) {
final org.geotoolkit.ogc.xml.v200.DistanceBufferType dstOp = (org.geotoolkit.ogc.xml.v200.DistanceBufferType) ops;
final org.geotoolkit.ogc.xml.v200.MeasureType dt = dstOp.getDistanceType();
Object opAny = dstOp.getAny();
if (opAny instanceof JAXBElement) {
opAny = ((JAXBElement) opAny).getValue();
}
if (!(opAny instanceof AbstractGeometryType)) {
throw new IllegalArgumentException("geometry type is unexpected:" + opAny);
}
final AbstractGeometryType geom = (AbstractGeometryType) opAny;
final String pnt = dstOp.getPropertyName();
final Expression geom1 = visitPropertyName(pnt);
final Expression geom2 = visit(geom);
// TODO marche pas ? ou est la distance ? Double.valueOf(dt.getContent());
final double distance = 0;
final String units = dt.getUom();
if (OGCJAXBStatics.FILTER_SPATIAL_DWITHIN.equalsIgnoreCase(OpName)) {
return filterFactory.dwithin(geom1, geom2, distance, units);
} else if (OGCJAXBStatics.FILTER_SPATIAL_BEYOND.equalsIgnoreCase(OpName)) {
return filterFactory.beyond(geom1, geom2, distance, units);
}
throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
} else if (ops instanceof org.geotoolkit.ogc.xml.v200.BBOXType) {
final org.geotoolkit.ogc.xml.v200.BBOXType binary = (org.geotoolkit.ogc.xml.v200.BBOXType) ops;
Object binAny = binary.getAny();
if (binAny instanceof JAXBElement) {
binAny = ((JAXBElement) binAny).getValue();
}
if (!(binAny instanceof EnvelopeType)) {
throw new IllegalArgumentException("geometry type is unexpected:" + binAny);
}
final EnvelopeType box = (EnvelopeType) binAny;
final String pnt = binary.getPropertyName();
final Expression geom;
if (pnt != null) {
geom = visitPropertyName(pnt);
} else {
geom = null;
}
final double minx = box.getLowerCorner().getOrdinate(0);
final double maxx = box.getUpperCorner().getOrdinate(0);
final double miny = box.getLowerCorner().getOrdinate(1);
final double maxy = box.getUpperCorner().getOrdinate(1);
final String srs = box.getSrsName();
if (OGCJAXBStatics.FILTER_SPATIAL_BBOX.equalsIgnoreCase(OpName)) {
return filterFactory.bbox(geom, minx, miny, maxx, maxy, srs);
}
throw new IllegalArgumentException("Illegal filter element" + OpName + " : " + ops);
}
throw new IllegalArgumentException("Unknowed filter element" + jax);
}
use of org.geotoolkit.kml.xml.v220.AbstractGeometryType in project geotoolkit by Geomatys.
the class KMLStore method convert.
private static Geometry convert(Object geomType) throws DataStoreException {
if (geomType instanceof JAXBElement)
geomType = ((JAXBElement) geomType).getValue();
Geometry geom = null;
if (geomType instanceof ModelType) {
final ModelType modelType = (ModelType) geomType;
final LocationType location = modelType.getLocation();
geom = GF.createPoint(new Coordinate(location.getLongitude(), location.getLatitude()));
} else if (geomType instanceof PointType) {
final PointType pointType = (PointType) geomType;
final List<String> coordinates = pointType.getCoordinates();
geom = GF.createPoint(toCoordinates(coordinates, 1, false));
} else if (geomType instanceof PolygonType) {
final PolygonType polygonType = (PolygonType) geomType;
final CoordinateSequence outter = toCoordinates(polygonType.getOuterBoundaryIs().getLinearRing().getCoordinates(), 3, true);
final List<BoundaryType> inners = polygonType.getInnerBoundaryIs();
final LinearRing[] holes = new LinearRing[inners.size()];
for (int i = 0; i < holes.length; i++) {
holes[i] = GF.createLinearRing(toCoordinates(inners.get(i).getLinearRing().getCoordinates(), 3, true));
}
geom = GF.createPolygon(GF.createLinearRing(outter), holes);
} else if (geomType instanceof LinearRingType) {
final LinearRingType linearRingType = (LinearRingType) geomType;
geom = GF.createLineString(toCoordinates(linearRingType.getCoordinates(), 3, true));
} else if (geomType instanceof MultiGeometryType) {
final MultiGeometryType multigeometryType = (MultiGeometryType) geomType;
final List<JAXBElement<? extends AbstractGeometryType>> children = multigeometryType.getAbstractGeometryGroup();
final Geometry[] childs = new Geometry[children.size()];
for (int i = 0; i < childs.length; i++) {
childs[i] = convert(children.get(i));
}
geom = GF.createGeometryCollection(childs);
} else if (geomType instanceof LineStringType) {
final LineStringType lineStringType = (LineStringType) geomType;
geom = GF.createLineString(toCoordinates(lineStringType.getCoordinates(), 2, false));
}
if (geom != null) {
JTS.setCRS(geom, CRS);
}
return geom;
}
Aggregations