use of org.geotoolkit.gml.xml.v212.CoordType in project ddf by codice.
the class CswQueryFactoryTest method createPolygon.
private JAXBElement<AbstractGeometryType> createPolygon() {
PolygonType localPolygon = new PolygonType();
LinearRingType ring = new LinearRingType();
for (Coordinate coordinate : polygon.getCoordinates()) {
CoordType coord = new CoordType();
coord.setX(BigDecimal.valueOf(coordinate.x));
coord.setY(BigDecimal.valueOf(coordinate.y));
if (!Double.isNaN(coordinate.z)) {
coord.setZ(BigDecimal.valueOf(coordinate.z));
}
ring.getCoord().add(coord);
}
AbstractRingPropertyType abstractRing = new AbstractRingPropertyType();
abstractRing.setRing(gmlObjectFactory.createLinearRing(ring));
localPolygon.setExterior(gmlObjectFactory.createExterior(abstractRing));
JAXBElement<AbstractGeometryType> agt = new JAXBElement<>(new QName("http://www.opengis.net/gml", "Polygon"), AbstractGeometryType.class, null, localPolygon);
return agt;
}
use of org.geotoolkit.gml.xml.v212.CoordType in project geotoolkit by Geomatys.
the class FilterToOGC100Converter method toBox.
/**
* Analyze given literal and try to transform it into GML 2 bbox. The
* conversion is possible only if the given literal contains an
* {@link Envelope} or a {@link GeographicBoundingBox}.
*
* @param input The literal to extract a bbox from.
* @return Built bbox, never null.
* @throws IllegalArgumentException If given literal does not contain any
* usable envelope. Note that an envelope cannot be used if its dimension is
* more than 2D and no CRS is present to allow us to find horizontal piece.
*/
private static BoxType toBox(final Literal input) throws IllegalArgumentException {
final Object val = input.getValue();
if (val == null) {
throw new IllegalArgumentException("No value in input literal object. Conversion to BoxType impossible");
}
final BoxType bType = new BoxType();
CoordinateReferenceSystem boxCrs = null;
if (val instanceof Envelope) {
final Envelope env = (Envelope) val;
boxCrs = env.getCoordinateReferenceSystem();
final int xAxis;
if (env.getDimension() == 2) {
xAxis = 0;
} else if (env.getDimension() > 2) {
if (boxCrs == null) {
throw new IllegalArgumentException("Cannot find horizontal axis of given envelope");
}
final SingleCRS hCrs = CRS.getHorizontalComponent(boxCrs);
if (hCrs == null) {
throw new IllegalArgumentException("Cannot find horizontal axis of given envelope");
}
xAxis = AxisDirections.indexOfColinear(boxCrs.getCoordinateSystem(), hCrs.getCoordinateSystem());
boxCrs = hCrs;
} else
throw new IllegalArgumentException(String.format("Given envelope has not enough dimension. Cannot build a bbox from it.%nExpected: %d%nBut was: %d", 2, env.getDimension()));
final int yAxis = xAxis + 1;
bType.getCoord().add(new CoordType(env.getMinimum(xAxis), env.getMinimum(yAxis)));
bType.getCoord().add(new CoordType(env.getMaximum(xAxis), env.getMaximum(yAxis)));
} else if (val instanceof GeographicBoundingBox) {
final GeographicBoundingBox e = (GeographicBoundingBox) val;
bType.getCoord().add(new CoordType(e.getWestBoundLongitude(), e.getSouthBoundLatitude()));
bType.getCoord().add(new CoordType(e.getEastBoundLongitude(), e.getNorthBoundLatitude()));
boxCrs = CommonCRS.defaultGeographic();
}
if (boxCrs != null) {
String srsName;
try {
srsName = IdentifiedObjects.lookupURN(boxCrs, null);
} catch (FactoryException ex) {
srsName = IdentifiedObjects.getSimpleNameOrIdentifier(boxCrs);
}
if (srsName != null) {
bType.setSrsName(srsName);
}
}
return bType;
}
use of org.geotoolkit.gml.xml.v212.CoordType in project geotoolkit by Geomatys.
the class WfsXMLBindingTest method marshallingTest.
@Test
public void marshallingTest() throws JAXBException {
WFSCapabilitiesType capa = new WFSCapabilitiesType();
List<FeatureTypeType> featList = new ArrayList<FeatureTypeType>();
LatLongBoundingBoxType bbox = new LatLongBoundingBoxType(29.8, -90.1, 30, -89.9);
FeatureTypeType ft1 = new FeatureTypeType(new QName("http://www.opengis.net/ows-6/utds/0.3", "Building", "utds"), "", "urn:ogc:def:crs:EPSG::4979", Arrays.asList(bbox));
featList.add(ft1);
FeatureTypeListType featureList = new FeatureTypeListType(null, featList);
capa.setFeatureTypeList(featureList);
StringWriter sw = new StringWriter();
marshaller.marshal(capa, sw);
DeleteElementType del = null;
TransactionType transac = new TransactionType("WFS", "1.1.0", null, AllSomeType.ALL, del);
PropertyIsLikeType pis = new PropertyIsLikeType("NAME", "Ashton", "*", "?", "\\");
org.geotoolkit.ogc.xml.v100.ObjectFactory factory = new org.geotoolkit.ogc.xml.v100.ObjectFactory();
final JAXBElement<? extends ComparisonOpsType> jbPis = factory.createPropertyIsLike(pis);
FilterType filter = new FilterType(null, jbPis, null, null);
CoordType dp = new CoordType(21400.0, 2001368.0);
PointType pt = new PointType(dp);
pt.setSrsName("urn:ogc:def:crs:epsg:7.4:27582");
PropertyType property = new PropertyType("the_geom", pt);
UpdateElementType update = new UpdateElementType(Arrays.asList(property), filter, new QName("http://www.opengis.net/gml", "NamedPlaces"));
transac.getInsertOrUpdateOrDelete().add(update);
// marshaller.marshal(transac, System.out);
}
Aggregations