// Created by plusminus on 18:59:46 - 19.01.2009 package org.androad.sys.ors.tuks; import java.util.Formatter; import java.util.Locale; import junit.framework.Assert; import org.osmdroid.util.BoundingBoxE6; import org.androad.sys.ors.util.constants.ORSXMLConstants; public class TUKSRequestComposer implements ORSXMLConstants { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== /** * <pre> * <wfs:GetFeature service="WFS" version="1.1.0" * xmlns:wfs="http://www.opengis.net/wfs" * xmlns:ogc="http://www.opengis.net/ogc" * xmlns:gml="http://www.opengis.net/gml" * xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" * xsi:schemaLocation="http://www.opengis.net/wfs * http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">; * <wfs:Query typeName="traffic:messages"> * <wfs:PropertyName>traffic:description</wfs:PropertyName> * <wfs:PropertyName>traffic:severity</wfs:PropertyName> * <wfs:PropertyName>traffic:the_geom</wfs:PropertyName> * <ogc:Filter> * <ogc:BBOX> * <ogc:PropertyName>the_geom</ogc:PropertyName> * <gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> * <gml:lowerCorner>-10.44161 58.82350</gml:lowerCorner> * <gml:upperCorner>2.26089 41.512517</gml:upperCorner> * </gml:Envelope> * </ogc:BBOX> * </ogc:Filter> * </wfs:Query> * </wfs:GetFeature></pre> * @param pBoundingBoxE6 * */ public static String createGML1(final BoundingBoxE6 pBoundingBoxE6){ Assert.assertNotNull(pBoundingBoxE6); final StringBuilder sb = new StringBuilder(); final Formatter f = new Formatter(sb, Locale.ENGLISH); sb.append(WFS_GETFEATURE_TAG_OPEN); f.format(WFS_QUERY_TAG_OPEN, "traffic:t_traffic_view"); // @HOME SERVER traffic:messages | @UNI traffic:t_traffic_view f.format(WFS_PROPERTY_TAG, "traffic:severity"); f.format(WFS_PROPERTY_TAG, "traffic:description"); f.format(WFS_PROPERTY_TAG, "traffic:the_geom"); sb.append(OGC_FILTER_TAG_OPEN) .append(OGC_BBOX_TAG_OPEN); f.format(OGC_PROPERTY_TAG, "the_geom"); /* The BoundingBox... */ sb.append(GML_ENVELOPE_TAG_OPEN); f.format(GML_LOWERCORNER_TAG, pBoundingBoxE6.getLonWestE6() / 1E6, pBoundingBoxE6.getLatSouthE6() / 1E6); f.format(GML_UPPERCORNER_TAG, pBoundingBoxE6.getLonEastE6() / 1E6, pBoundingBoxE6.getLatNorthE6() / 1E6); sb.append(GML_ENVELOPE_TAG_CLOSE) .append(OGC_BBOX_TAG_CLOSE) .append(OGC_FILTER_TAG_CLOSE) .append(WFS_QUERY_TAG_CLOSE) .append(WFS_GETFEATURE_TAG_CLOSE); return sb.toString(); } /** <pre><wfs:GetFeature service="WFS" version="1.0.0" * outputFormat="GML2" * xmlns:topp="http://www.openplans.org/topp" * xmlns:wfs="http://www.opengis.net/wfs" * xmlns:ogc="http://www.opengis.net/ogc" * xmlns:gml="http://www.opengis.net/gml" * xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" * xsi:schemaLocation="http://www.opengis.net/wfs * http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd"> * <wfs:Query typeName="traffic:messages"> * <wfs:PropertyName>traffic:id</wfs:PropertyName> * <wfs:PropertyName>traffic:description</wfs:PropertyName> * <wfs:PropertyName>traffic:severity</wfs:PropertyName> * <wfs:PropertyName>traffic:the_geom</wfs:PropertyName> * <ogc:Filter> * <ogc:BBOX> * <ogc:PropertyName>the_geom</ogc:PropertyName> * <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> * <gml:coordinates>0.0,51.0 -1.0,52.0</gml:coordinates> * </gml:Box> * </ogc:BBOX> * </ogc:Filter> * </wfs:Query> * </wfs:GetFeature></pre> * @param pBoundingBoxE6 * */ public static String createGML2(final BoundingBoxE6 pBoundingBoxE6){ Assert.assertNotNull(pBoundingBoxE6); final StringBuilder sb = new StringBuilder(); final Formatter f = new Formatter(sb, Locale.ENGLISH); sb.append(WFS_GETFEATURE_TAG_GML2_OPEN); f.format(WFS_QUERY_TAG_OPEN, "traffic:t_traffic_view"); // @HOME SERVER traffic:messages | @UNI traffic:t_traffic_view f.format(WFS_PROPERTY_TAG, "traffic:severity"); f.format(WFS_PROPERTY_TAG, "traffic:description"); f.format(WFS_PROPERTY_TAG, "traffic:the_geom"); sb.append(OGC_FILTER_TAG_OPEN) .append(OGC_BBOX_TAG_OPEN); f.format(OGC_PROPERTY_TAG, "the_geom"); /* The BoundingBox... */ sb.append(GML_BOX_TAG_OPEN); f.format(GML_COORDINATES_TAG, pBoundingBoxE6.getLonEastE6() / 1E6, pBoundingBoxE6.getLatSouthE6() / 1E6, pBoundingBoxE6.getLonWestE6() / 1E6, pBoundingBoxE6.getLatNorthE6() / 1E6); sb.append(GML_BOX_TAG_CLOSE) .append(OGC_BBOX_TAG_CLOSE) .append(OGC_FILTER_TAG_CLOSE) .append(WFS_QUERY_TAG_CLOSE) .append(WFS_GETFEATURE_TAG_CLOSE); return sb.toString(); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }