public static boolean checkLocationGMLPoint(DigestType digest, String pos) { boolean foundPointLocation = false; List<LocationType> locationElements = EMDigestHelper.getLocationElements(digest); for (LocationType location : locationElements) { XmlObject[] geoLocations = location.selectChildren( gov.ucore.ucore.x20.GeoLocationType.type.getName().getNamespaceURI(), "GeoLocation"); if (geoLocations != null && geoLocations.length > 0) { for (XmlObject object : geoLocations) { GeoLocationType geo = (GeoLocationType) object; XmlObject[] UcorePoint = geo.selectChildren( gov.ucore.ucore.x20.PointType.type.getName().getNamespaceURI(), "Point"); if (UcorePoint.length > 0) { gov.ucore.ucore.x20.PointType point = (gov.ucore.ucore.x20.PointType) UcorePoint[0]; if (point.getPoint().getPos().getStringValue().equals(pos)) { foundPointLocation = true; } } } } } return foundPointLocation; }
public static boolean checkLocationGMLCircle(DigestType digest, String radius, String UOM) { boolean foundCircle = false; List<LocationType> locationElements = EMDigestHelper.getLocationElements(digest); for (LocationType location : locationElements) { XmlObject[] geoLocations = location.selectChildren( gov.ucore.ucore.x20.GeoLocationType.type.getName().getNamespaceURI(), "GeoLocation"); if (geoLocations != null && geoLocations.length > 0) { for (XmlObject object : geoLocations) { GeoLocationType geo = (GeoLocationType) object; XmlObject[] ucoreCircles = geo.selectChildren( CircleByCenterPointType.type.getName().getNamespaceURI(), "CircleByCenterPoint"); if (ucoreCircles.length > 0) { // TODO: should check point value and UOM CircleByCenterPointType circle = (CircleByCenterPointType) ucoreCircles[0]; if (circle.getCircleByCenterPoint().getRadius().getStringValue().equals(radius) && circle.getCircleByCenterPoint().getRadius().getUom().equals(UOM) && circle.getCircleByCenterPoint().getNumArc() != null) { foundCircle = true; } } } } } return foundCircle; }
public static boolean checkLocationGMLPolygon(DigestType digest, List<String> points) { boolean foundPolygon = false; List<LocationType> locationElements = EMDigestHelper.getLocationElements(digest); for (LocationType location : locationElements) { XmlObject[] geoLocations = location.selectChildren( gov.ucore.ucore.x20.GeoLocationType.type.getName().getNamespaceURI(), "GeoLocation"); if (geoLocations != null && geoLocations.length > 0) { for (XmlObject object : geoLocations) { GeoLocationType geo = (GeoLocationType) object; XmlObject[] ucorePolygons = geo.selectChildren( gov.ucore.ucore.x20.PointType.type.getName().getNamespaceURI(), "Polygon"); if (ucorePolygons.length > 0) { for (XmlObject poly : ucorePolygons) { if (poly instanceof PolygonType) { net.opengis.gml.x32.PolygonType polygon = ((PolygonType) poly).getPolygon(); if (polygon.getExterior() != null && polygon.getExterior().getAbstractRing() != null) { if (polygon.getExterior().getAbstractRing() instanceof net.opengis.gml.x32.LinearRingType) { net.opengis.gml.x32.LinearRingType linearRing = (net.opengis.gml.x32.LinearRingType) polygon.getExterior().getAbstractRing(); if (linearRing.sizeOfPosArray() == points.size()) { foundPolygon = true; // TODO: check the values } } } } } } } } } return foundPolygon; }