public static boolean checkLocationAddresses(DigestType digest) { boolean foundPointLocation = false; List<LocationType> locationElements = EMDigestHelper.getLocationElements(digest); for (LocationType location : locationElements) { XmlObject[] addresses = location.selectChildren( gov.ucore.ucore.x20.PhysicalAddressType.type.getName().getNamespaceURI(), "PhysicalAddress"); if (addresses != null && addresses.length > 0) { for (XmlObject object : addresses) { PhysicalAddressType address = (PhysicalAddressType) object; if (address.getPostalAddress() != null) { if (address.getPostalAddress().getCountryCode() != null && address.getPostalAddress().getCountryCode().getQualifier() != null && address.getPostalAddress().getCountryCode().getValue() != null && address.getPostalAddress().getState() != null && address.getPostalAddress().getCity() != null && address.getPostalAddress().getPostalCode() != null && address.getPostalAddress().sizeOfStreetArray() > 0) { foundPointLocation = true; } } } } } return foundPointLocation; }
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; }