Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libGeocoding / src / org / gvsig / geocoding / styles / Composed.java @ 27057

History | View | Annotate | Download (5.93 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 Prodevelop S.L. main development
26
 */
27

    
28
package org.gvsig.geocoding.styles;
29

    
30
import java.util.ArrayList;
31
import java.util.List;
32
import java.util.Set;
33
import java.util.TreeSet;
34

    
35
import org.gvsig.geocoding.Address;
36
import org.gvsig.geocoding.Literal;
37
import org.gvsig.geocoding.geommatches.MatcherUtils;
38
import org.gvsig.geocoding.result.DissolveResult;
39
import org.gvsig.geocoding.result.GeocodingResult;
40
import org.gvsig.geocoding.result.GeomMatchResult;
41
import org.gvsig.geocoding.result.ScoredFeature;
42

    
43
/**
44
 * 
45
 * 
46
 * @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
47
 * @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a>
48
 */
49

    
50
public class Composed extends AbstractGeocodingStyle {
51

    
52
        private List<Literal> intersectsLiterals;
53

    
54
        /**
55
         * 
56
         * @return
57
         */
58
        public List<Literal> getIntersectsLiterals() {
59
                return intersectsLiterals;
60
        }
61

    
62
        /**
63
         * 
64
         * @param intersectName
65
         */
66
        public void setIntersectsLiterals(List<Literal> intersects) {
67
                this.intersectsLiterals = intersects;
68
        }
69

    
70
        @Override
71
        public Set<GeocodingResult> match(List listLists, Address address) {
72

    
73
                List<ScoredFeature> mainList = (List<ScoredFeature>) listLists.get(0);
74
                List<ScoredFeature> secondList = (List<ScoredFeature>) listLists.get(1);
75
                // this list store dissolve element of the first intersection (cross)
76
                List<ScoredFeature> crossList = new ArrayList<ScoredFeature>();
77

    
78
                for (ScoredFeature maRes : mainList) {
79
                        com.vividsolutions.jts.geom.Geometry mainGeomJTS = MatcherUtils
80
                                        .parseGeomGVToJTS(maRes.getDefaultGeometry());
81
                        for (ScoredFeature secRes : secondList) {
82
                                com.vividsolutions.jts.geom.Geometry secGeomJTS = MatcherUtils
83
                                                .parseGeomGVToJTS(secRes.getDefaultGeometry());
84
                                if (mainGeomJTS.touches(secGeomJTS)) {
85
                                        crossList.add(maRes);
86
                                        break;
87
                                }
88
                        }
89
                }
90

    
91
                // Triple Intersect (Cross Streets)
92

    
93
                // this list store dissolve element of the second intersection (three
94
                // intersection)
95
                List<ScoredFeature> reslist = new ArrayList<ScoredFeature>();
96

    
97
                if (listLists.size() == 3) {
98
                        List<ScoredFeature> thirdList = (List<ScoredFeature>) listLists
99
                                        .get(2);
100
                        for (int i = 0; i < crossList.size(); i++) {
101
                                ScoredFeature mainCrossFeat = crossList.get(i);
102
                                com.vividsolutions.jts.geom.Geometry mainCrossGeomJTS = MatcherUtils
103
                                                .parseGeomGVToJTS(mainCrossFeat.getDefaultGeometry());
104
                                for (ScoredFeature thiRes : thirdList) {
105
                                        com.vividsolutions.jts.geom.Geometry thiGeomJTS = MatcherUtils
106
                                                        .parseGeomGVToJTS(thiRes.getDefaultGeometry());
107
                                        if (mainCrossGeomJTS.touches(thiGeomJTS)) {
108
                                                reslist.add(mainCrossFeat);
109
                                                break;
110
                                        }
111
                                }
112

    
113
                        }
114
                }
115

    
116
                Set<GeocodingResult> fin = new TreeSet<GeocodingResult>();
117
                if (listLists.size() == 2) {
118
                        for (ScoredFeature res : crossList) {
119
                                GeomMatchResult mat = new GeomMatchResult();
120

    
121
                        }
122
                }
123
                if (listLists.size() == 3) {
124
                        for (ScoredFeature res : reslist) {
125
                                GeomMatchResult mat = new GeomMatchResult();
126

    
127
                        }
128
                }
129

    
130
                return fin;
131
        }
132

    
133
        /**
134
         * 
135
         * @param listLists
136
         * @return
137
         */
138
        private Set<GeocodingResult> multiIntersect(
139
                        List<List<DissolveResult>> listLists) {
140

    
141
                List<DissolveResult> mainList = listLists.get(0);
142
                List<DissolveResult> secondList = listLists.get(1);
143
                // this list store dissolve element of the first intersection (cross)
144
                List<DissolveResult> crossList = new ArrayList<DissolveResult>();
145

    
146
                for (DissolveResult maRes : mainList) {
147
                        com.vividsolutions.jts.geom.Geometry mainGeomJTS = MatcherUtils
148
                                        .parseGeomGVToJTS(maRes.getGeom());
149
                        for (DissolveResult secRes : secondList) {
150
                                com.vividsolutions.jts.geom.Geometry secGeomJTS = MatcherUtils
151
                                                .parseGeomGVToJTS(secRes.getGeom());
152
                                if (mainGeomJTS.touches(secGeomJTS)) {
153
                                        crossList.add(maRes);
154
                                        break;
155
                                }
156
                        }
157
                }
158

    
159
                // Triple Intersect (Cross Streets)
160

    
161
                // this list store dissolve element of the second intersection (three
162
                // intersection)
163
                List<DissolveResult> reslist = new ArrayList<DissolveResult>();
164

    
165
                if (listLists.size() == 3) {
166
                        List<DissolveResult> thirdList = listLists.get(2);
167
                        for (int i = 0; i < crossList.size(); i++) {
168
                                DissolveResult mainCrossRes = crossList.get(i);
169
                                com.vividsolutions.jts.geom.Geometry mainCrossGeomJTS = MatcherUtils
170
                                                .parseGeomGVToJTS(mainCrossRes.getGeom());
171
                                for (DissolveResult thiRes : thirdList) {
172
                                        com.vividsolutions.jts.geom.Geometry thiGeomJTS = MatcherUtils
173
                                                        .parseGeomGVToJTS(thiRes.getGeom());
174
                                        if (mainCrossGeomJTS.touches(thiGeomJTS)) {
175
                                                reslist.add(mainCrossRes);
176
                                                break;
177
                                        }
178
                                }
179

    
180
                        }
181
                }
182

    
183
                Set<GeocodingResult> fin = new TreeSet<GeocodingResult>();
184
                if (listLists.size() == 2) {
185
                        for (DissolveResult res : crossList) {
186
                                GeomMatchResult mat = new GeomMatchResult();
187

    
188
                        }
189
                }
190
                if (listLists.size() == 3) {
191
                        for (DissolveResult res : reslist) {
192
                                GeomMatchResult mat = new GeomMatchResult();
193

    
194
                        }
195
                }
196

    
197
                return null;
198
        }
199

    
200
}