Statistics
| Revision:

root / org.gvsig.wfs.app / trunk / org.gvsig.wfs.app / org.gvsig.wfs.app.mainplugin / src / main / java / org / gvsig / remoteclient / wfs / filters / filterencoding / wfs_1_1_0 / GeometryFEQuery_1_1_0.java @ 112

History | View | Annotate | Download (3.43 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

    
25
package org.gvsig.remoteclient.wfs.filters.filterencoding.wfs_1_1_0;
26

    
27
import java.awt.geom.PathIterator;
28

    
29
import org.gvsig.fmap.geom.Geometry;
30
import org.gvsig.fmap.geom.Geometry.TYPES;
31
import org.gvsig.fmap.geom.primitive.GeneralPathX;
32
import org.gvsig.fmap.geom.primitive.Surface;
33
import org.gvsig.remoteclient.wfs.filters.filterencoding.GeometryFEQuery;
34
import org.gvsig.remoteclient.wfs.filters.operations.WFSGeometryFilterOperation;
35

    
36
/**
37
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
38
 */
39
public class GeometryFEQuery_1_1_0 extends GeometryFEQuery{
40

    
41
        public GeometryFEQuery_1_1_0(WFSGeometryFilterOperation geometryOperation) {
42
                super(geometryOperation);
43
        }
44

    
45
        public String getFilterEncoding(){
46
                StringBuffer request = new StringBuffer();
47
                if (geometry.getType() == TYPES.SURFACE){
48
                        Surface surface = (Surface)geometry;
49
                        request.append("<ogc:Intersects>");
50
                        request.append("<ogc:PropertyName>" + spatialFilterOperation.getAttributeName() + "</ogc:PropertyName>");
51
                        request.append("<gml:MultiSurface srsName=\"" + spatialFilterOperation.getSrsName() + "\">");
52
                        request.append("<gml:surfaceMember>");
53
                        request.append("<gml:Polygon>");
54
                        request.append("<gml:exterior>");
55
                        request.append("<gml:LinearRing>");
56
                        request.append("<gml:coordinates cs=\",\" decimal=\".\" ts=\" \">");
57
                        GeneralPathX generalPath = surface.getGeneralPath();
58
                        PathIterator it = generalPath.getPathIterator(null);
59
                        int type;
60
                        double[] coordinates = new double[6];
61
                        double[] firstCoordinates = null;
62
                        while (!it.isDone()){
63
                                type = it.currentSegment(coordinates);
64
                                switch (type) {
65
                                        case PathIterator.SEG_MOVETO:
66
                                        case PathIterator.SEG_LINETO:
67
                                                request.append(coordinates[0]);
68
                                                request.append(",");
69
                                                request.append(coordinates[1]);
70
                                                request.append(" ");
71
                                                if (firstCoordinates == null){
72
                                                        firstCoordinates = new double[2];
73
                                                        firstCoordinates[0] = coordinates[0];
74
                                                        firstCoordinates[1] = coordinates[1];
75
                                                }
76
                                                break;
77
                                }
78
                                it.next();
79
                        }
80
                        if ((coordinates[0] != firstCoordinates[0]) ||
81
                                        (coordinates[1] != firstCoordinates[1])){
82
                                request.append(firstCoordinates[0]);
83
                                request.append(",");
84
                                request.append(firstCoordinates[1]);
85
                        }
86
                        request.append("</gml:coordinates>");
87
                        request.append("</gml:LinearRing>");
88
                        request.append("</gml:exterior>");
89
                        request.append("</gml:Polygon>");
90
                        request.append("</gml:surfaceMember>");
91
                        request.append("</gml:MultiSurface>");
92
                        request.append("</ogc:Intersects>");
93
                }
94
                return request.toString();
95
        }
96

    
97

    
98
}
99