OGC WFS Filter学习心得

private String formatFilter(String coordinates, String radius, String properName) {
    StringBuffer buffer = new StringBuffer();
    buffer.append("<ogc:Filter><ogc:Intersects>");
    buffer.append("<ogc:PropertyName>Shape</ogc:PropertyName>");
    if (StringUtils.isNotBlank(radius)) {
        //圈选
        buffer.append("<gml:Point srsName=\"http://www.opengis.net/gml/srs/epsg.xml#4326\">");
        buffer.append("<gml:coordinates>"+convertSort(coordinates)+"</gml:coordinates>");
        buffer.append("</gml:Point>");
        buffer.append("<ogc:Distance unit=\"m\">"+radius+"</ogc:Distance>");
    } else {
        if (coordinates.indexOf(";") > -1) {
            String coorArr[] = coordinates.split(";");
            String coors = "";
            int coorArrLen = coorArr.length;
           // 框选
            buffer.append("<gml:Polygon srsName=\"http://www.opengis.net/gml/srs/epsg.xml#4326\">");
            buffer.append("<gml:outerBoundaryIs>");
            buffer.append("<gml:LinearRing>");
            for (int i = 0; i < coorArrLen; i++) {
                String coor = convertSort(coorArr[i]);
                coors += coor + " ";
            }
            coors = coors.substring(0, coors.length() - 1);
            buffer.append("<gml:coordinates>" + coors + " </gml:coordinates>");
            buffer.append("</gml:LinearRing>");
            buffer.append("</gml:outerBoundaryIs>");
            buffer.append("</gml:Polygon>");
        } else {
           // 点选
            buffer.append("<gml:Point srsName=\"http://www.opengis.net/gml/srs/epsg.xml#4326\">");
            buffer.append("<gml:coordinates>" + convertSort(coordinates) + "</gml:coordinates>");
            buffer.append("</gml:Point>");

        }
    }
    buffer.append("</ogc:Intersects>");
    buffer.append("</ogc:Filter>");
    return buffer.toString();


}

Filter是用的Intersects,

convertSort(str)做了个坐标互换位置

调用的ArcGis server发布的WFS

转载自:https://blog.csdn.net/qq_40265503/article/details/80446496

You may also like...