Revision 27057
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/NumberAddress.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
public class NumberAddress extends Address { |
38 | 38 |
|
39 |
|
|
39 |
private int number; |
|
40 | 40 |
|
41 |
private int number; |
|
42 |
|
|
43 | 41 |
/** |
44 | 42 |
* Constructor with main literal |
43 |
* |
|
45 | 44 |
* @param main |
46 | 45 |
*/ |
47 | 46 |
public NumberAddress(Literal main) { |
48 | 47 |
super(main); |
49 |
|
|
48 |
|
|
50 | 49 |
} |
51 |
|
|
50 |
|
|
52 | 51 |
/** |
53 | 52 |
* Constructor with main literal |
53 |
* |
|
54 | 54 |
* @param main |
55 | 55 |
*/ |
56 | 56 |
public NumberAddress(Literal main, int number) { |
57 | 57 |
super(main); |
58 | 58 |
this.number = number; |
59 |
|
|
59 |
|
|
60 | 60 |
} |
61 | 61 |
|
62 | 62 |
/** |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/result/GeomMatchResult.java | ||
---|---|---|
40 | 40 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a> |
41 | 41 |
*/ |
42 | 42 |
|
43 |
public class GeomMatchResult implements GeocodingResult, Comparable<GeomMatchResult> { |
|
43 |
public class GeomMatchResult implements GeocodingResult, |
|
44 |
Comparable<GeomMatchResult> { |
|
44 | 45 |
|
45 | 46 |
private List<ScoredFeature> sources = new ArrayList<ScoredFeature>(); |
46 | 47 |
private Geometry geom = null; |
... | ... | |
64 | 65 |
/** |
65 | 66 |
* |
66 | 67 |
*/ |
67 |
public double getScore() {
|
|
68 |
public double getScore() { |
|
68 | 69 |
return score; |
69 | 70 |
} |
70 | 71 |
|
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/DataGeocoder.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.geocoding; |
29 | 29 |
|
30 |
import org.gvsig.fmap.dal.DataManager; |
|
31 | 30 |
import org.gvsig.geocoding.pattern.Patterngeocoding; |
32 | 31 |
|
33 | 32 |
/** |
... | ... | |
39 | 38 |
*/ |
40 | 39 |
public interface DataGeocoder extends Geocoder { |
41 | 40 |
|
42 |
|
|
43 | 41 |
/** |
44 | 42 |
* |
45 | 43 |
* @param pat |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/DataGeocoderImpl.java | ||
---|---|---|
32 | 32 |
import java.util.List; |
33 | 33 |
import java.util.Map; |
34 | 34 |
import java.util.Set; |
35 |
import java.util.TreeSet; |
|
36 | 35 |
|
37 | 36 |
import org.apache.log4j.Logger; |
38 | 37 |
import org.gvsig.fmap.dal.DALLocator; |
... | ... | |
45 | 44 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
46 | 45 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
47 | 46 |
import org.gvsig.geocoding.pattern.Patterngeocoding; |
48 |
import org.gvsig.geocoding.result.DissolveResult; |
|
49 | 47 |
import org.gvsig.geocoding.result.GeocodingResult; |
50 | 48 |
import org.gvsig.geocoding.result.ScoredFeature; |
51 | 49 |
import org.gvsig.geocoding.styles.AbstractGeocodingStyle; |
52 |
import org.gvsig.geocoding.styles.Centroid; |
|
53 | 50 |
import org.gvsig.geocoding.styles.Composed; |
54 | 51 |
import org.gvsig.geocoding.styles.DoubleRange; |
52 |
import org.gvsig.geocoding.styles.SimpleCentroid; |
|
55 | 53 |
import org.gvsig.geocoding.styles.SimpleRange; |
56 | 54 |
import org.gvsig.tools.evaluator.Evaluator; |
57 | 55 |
import org.gvsig.tools.locator.LocatorException; |
... | ... | |
106 | 104 |
throws LocatorException, DataException { |
107 | 105 |
|
108 | 106 |
FeatureStore store = getPattern().getSource().getLayerSource(); |
109 |
AbstractGeocodingStyle astyle = getPattern().getSource().getStyle();
|
|
107 |
AbstractGeocodingStyle astyle = getPattern().getSource().getStyle(); |
|
110 | 108 |
Set<GeocodingResult> geomResults = null; |
111 | 109 |
|
112 | 110 |
Literal literalRelations = astyle.getMainLiteral(); |
... | ... | |
116 | 114 |
SimpleRange style = (SimpleRange) astyle; |
117 | 115 |
Literal literalAddress = ((NumberAddress) address).getMainLiteral(); |
118 | 116 |
// literal search |
119 |
List<ScoredFeature> litResults = literalSearch(literalRelations, literalAddress, store); |
|
117 |
List<ScoredFeature> litResults = literalSearch(literalRelations, |
|
118 |
literalAddress, store); |
|
120 | 119 |
// geom search |
121 | 120 |
geomResults = style.match(litResults, address); |
122 | 121 |
} |
... | ... | |
126 | 125 |
DoubleRange style = (DoubleRange) astyle; |
127 | 126 |
Literal literalAddress = ((NumberAddress) address).getMainLiteral(); |
128 | 127 |
// literal search |
129 |
List<ScoredFeature> litResults = literalSearch(literalRelations, literalAddress, store); |
|
128 |
List<ScoredFeature> litResults = literalSearch(literalRelations, |
|
129 |
literalAddress, store); |
|
130 | 130 |
// number search |
131 | 131 |
geomResults = style.match(litResults, address); |
132 | 132 |
} |
133 | 133 |
|
134 | 134 |
// SIMPLE CENTROID |
135 |
else if (astyle instanceof Centroid) { |
|
136 |
Centroid style = (Centroid) astyle;
|
|
135 |
else if (astyle instanceof SimpleCentroid) {
|
|
136 |
SimpleCentroid style = (SimpleCentroid) astyle;
|
|
137 | 137 |
Literal mainLiteral = address.getMainLiteral(); |
138 | 138 |
// literal search |
139 |
List<ScoredFeature> litResults = literalSearch(literalRelations, mainLiteral, store); |
|
139 |
List<ScoredFeature> litResults = literalSearch(literalRelations, |
|
140 |
mainLiteral, store); |
|
140 | 141 |
// Geom search |
141 | 142 |
geomResults = style.match(litResults, address); |
142 | 143 |
} |
143 | 144 |
|
144 | 145 |
// STYLE COMPOSED |
145 | 146 |
else if (astyle instanceof Composed) { |
146 |
|
|
147 |
|
|
147 | 148 |
List<List<ScoredFeature>> resResults = new ArrayList<List<ScoredFeature>>(); |
148 |
|
|
149 |
|
|
149 | 150 |
Composed style = (Composed) astyle; |
150 | 151 |
ComposeAddress cAddress = (ComposeAddress) address; |
151 | 152 |
|
152 | 153 |
// main literal search |
153 | 154 |
Literal mainLiteralAddress = cAddress.getMainLiteral(); |
154 |
List<ScoredFeature> litResults = literalSearch(literalRelations, mainLiteralAddress,
|
|
155 |
store); |
|
155 |
List<ScoredFeature> litResults = literalSearch(literalRelations, |
|
156 |
mainLiteralAddress, store);
|
|
156 | 157 |
resResults.add(litResults); |
157 | 158 |
// search in others literals |
158 | 159 |
List<Literal> intersectslist = cAddress.getIntersectionLiteral(); |
... | ... | |
162 | 163 |
addrLiteral, store); |
163 | 164 |
resResults.add(secList); |
164 | 165 |
} |
165 |
//Match |
|
166 |
// Match
|
|
166 | 167 |
geomResults = style.match(resResults, address); |
167 | 168 |
} |
168 | 169 |
return geomResults; |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/styles/Centroid.java | ||
---|---|---|
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.fmap.dal.feature.FeatureAttributeDescriptor; |
|
36 |
import org.gvsig.fmap.geom.Geometry; |
|
37 |
import org.gvsig.fmap.geom.primitive.Point2D; |
|
38 |
import org.gvsig.geocoding.Address; |
|
39 |
import org.gvsig.geocoding.geommatches.MatcherUtils; |
|
40 |
import org.gvsig.geocoding.result.DissolveResult; |
|
41 |
import org.gvsig.geocoding.result.GeocodingResult; |
|
42 |
import org.gvsig.geocoding.result.GeomMatchResult; |
|
43 |
import org.gvsig.geocoding.result.ScoredFeature; |
|
44 |
|
|
45 |
/** |
|
46 |
* |
|
47 |
* |
|
48 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a> |
|
49 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a> |
|
50 |
*/ |
|
51 |
|
|
52 |
public class Centroid extends Simple { |
|
53 |
|
|
54 |
@Override |
|
55 |
public Set<GeocodingResult> match(List inFeats, Address address) { |
|
56 |
|
|
57 |
Set<GeocodingResult> geocoRes = new TreeSet<GeocodingResult>(); |
|
58 |
|
|
59 |
// catch the first element of the main Literal to get the field |
|
60 |
// descriptor |
|
61 |
// to make the dissolve |
|
62 |
FeatureAttributeDescriptor desc = (FeatureAttributeDescriptor) this |
|
63 |
.getMainLiteral().get(0).getValue(); |
|
64 |
|
|
65 |
// POINTs FEATURES |
|
66 |
if (((ScoredFeature) inFeats.get(0)).getDefaultGeometry() |
|
67 |
.getDimension() == 0) { |
|
68 |
geocoRes = createPointsFeaturesResult(inFeats); |
|
69 |
} |
|
70 |
// OTHER GEOMETRIES TYPES |
|
71 |
else { |
|
72 |
// dissolve features selected |
|
73 |
List<DissolveResult> disRes = super.dissolveScoredFeatures(desc, |
|
74 |
inFeats); |
|
75 |
|
|
76 |
for (DissolveResult dis : disRes) { |
|
77 |
GeomMatchResult matchres = new GeomMatchResult(); |
|
78 |
Point2D position = null; |
|
79 |
|
|
80 |
Geometry geom = dis.getGeom(); |
|
81 |
// Points |
|
82 |
if (geom.getDimension() == 0) { |
|
83 |
// TODO faltan los puntos |
|
84 |
} |
|
85 |
// Lines |
|
86 |
if (geom.getDimension() == 1) { |
|
87 |
com.vividsolutions.jts.geom.Geometry geoJTS = MatcherUtils |
|
88 |
.parseGeomGVToJTS(geom); |
|
89 |
position = MatcherUtils |
|
90 |
.getLinePositionFromRelativeDistance(geoJTS, 50); |
|
91 |
} |
|
92 |
// Polys |
|
93 |
if (geom.getDimension() == 2) { |
|
94 |
position = MatcherUtils.internalPointGeometry(geom); |
|
95 |
} |
|
96 |
matchres.setGeom(position); |
|
97 |
matchres.setSources(dis.getScoredFeatures()); |
|
98 |
geocoRes.add(matchres); |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
return geocoRes; |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 |
* |
|
107 |
* @param inFeats |
|
108 |
* @return |
|
109 |
*/ |
|
110 |
private Set<GeocodingResult> createPointsFeaturesResult( |
|
111 |
List<ScoredFeature> inFeats) { |
|
112 |
|
|
113 |
Set<GeocodingResult> results = new TreeSet<GeocodingResult>(); |
|
114 |
|
|
115 |
for (ScoredFeature feat : inFeats) { |
|
116 |
GeomMatchResult res = new GeomMatchResult(); |
|
117 |
res.setGeom(feat.getDefaultGeometry()); |
|
118 |
List<ScoredFeature> sources = new ArrayList<ScoredFeature>(); |
|
119 |
sources.add(feat); |
|
120 |
res.setSources(sources); |
|
121 |
results.add(res); |
|
122 |
} |
|
123 |
return results; |
|
124 |
} |
|
125 |
|
|
126 |
} |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/styles/Simple.java | ||
---|---|---|
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.HashMap; |
|
32 |
import java.util.Iterator; |
|
33 |
import java.util.List; |
|
34 |
import java.util.Map; |
|
35 |
|
|
36 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
37 |
import org.gvsig.geocoding.geommatches.MatcherUtils; |
|
38 |
import org.gvsig.geocoding.result.DissolveResult; |
|
39 |
import org.gvsig.geocoding.result.ScoredFeature; |
|
40 |
|
|
41 |
/** |
|
42 |
* |
|
43 |
* |
|
44 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a> |
|
45 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a> |
|
46 |
*/ |
|
47 |
|
|
48 |
public abstract class Simple extends AbstractGeocodingStyle { |
|
49 |
|
|
50 |
/** |
|
51 |
* Dissolve features geometry behind one folder |
|
52 |
* |
|
53 |
* @param field |
|
54 |
* @param features |
|
55 |
*/ |
|
56 |
public List<DissolveResult> dissolveScoredFeatures( |
|
57 |
FeatureAttributeDescriptor field, List<ScoredFeature> features) { |
|
58 |
|
|
59 |
List<DissolveResult> listResults = new ArrayList<DissolveResult>(); |
|
60 |
|
|
61 |
// Group geometries by main attribute |
|
62 |
HashMap<String, List<ScoredFeature>> dissolAttributes = MatcherUtils |
|
63 |
.groupScoredFeaturesByAttribute(field, features); |
|
64 |
|
|
65 |
// For each group of features, to do geometries dissolve process getting |
|
66 |
// at the end one o more geometries |
|
67 |
for (Iterator<Map.Entry<String, List<ScoredFeature>>> iterator = dissolAttributes |
|
68 |
.entrySet().iterator(); iterator.hasNext();) { |
|
69 |
Map.Entry<String, List<ScoredFeature>> e = iterator.next(); |
|
70 |
List<ScoredFeature> feats = e.getValue(); |
|
71 |
|
|
72 |
// dissolve Lines (if first geometry of array is Line) |
|
73 |
List<DissolveResult> geomsDissol = null; |
|
74 |
if (feats.get(0).getDefaultGeometry().getDimension() == 1) { |
|
75 |
geomsDissol = MatcherUtils.dissolveLinesJTS(feats); |
|
76 |
} |
|
77 |
// dissolve Polys (if first geometry of array is Poly) |
|
78 |
if (feats.get(0).getDefaultGeometry().getDimension() == 2) { |
|
79 |
geomsDissol = MatcherUtils.dissolvePolysJTS(feats); |
|
80 |
} |
|
81 |
// insert each dissolve result in the general array |
|
82 |
for (DissolveResult dissolveResult : geomsDissol) { |
|
83 |
listResults.add(dissolveResult); |
|
84 |
} |
|
85 |
} |
|
86 |
return listResults; |
|
87 |
} |
|
88 |
|
|
89 |
} |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/styles/SimpleRange.java | ||
---|---|---|
37 | 37 |
import org.gvsig.fmap.geom.Geometry; |
38 | 38 |
import org.gvsig.fmap.geom.primitive.Point2D; |
39 | 39 |
import org.gvsig.geocoding.Address; |
40 |
import org.gvsig.geocoding.AddressComponent; |
|
41 | 40 |
import org.gvsig.geocoding.NumberAddress; |
42 | 41 |
import org.gvsig.geocoding.RelationsComponent; |
43 | 42 |
import org.gvsig.geocoding.geommatches.MatcherUtils; |
... | ... | |
125 | 124 |
*/ |
126 | 125 |
@Override |
127 | 126 |
public void setState(PersistentState state) throws PersistenceException { |
128 |
this.firstNumber = (RelationsComponent)state.get(FIRSTNUMBER); |
|
129 |
this.lastNumber = (RelationsComponent)state.get(LASTNUMBER); |
|
127 |
this.firstNumber = (RelationsComponent) state.get(FIRSTNUMBER);
|
|
128 |
this.lastNumber = (RelationsComponent) state.get(LASTNUMBER);
|
|
130 | 129 |
} |
131 | 130 |
|
132 | 131 |
/** |
... | ... | |
143 | 142 |
|
144 | 143 |
for (Iterator it = inFeats.iterator(); it.hasNext();) { |
145 | 144 |
ScoredFeature feat = (ScoredFeature) it.next(); |
146 |
|
|
147 |
int number = ((NumberAddress)address).getNumber(); |
|
148 |
|
|
145 |
|
|
146 |
int number = ((NumberAddress) address).getNumber();
|
|
147 |
|
|
149 | 148 |
int first = feat.getInt(firstNumberDesc.getName()); |
150 | 149 |
int last = feat.getInt(lastNumbnerDesc.getName()); |
151 | 150 |
|
... | ... | |
159 | 158 |
} |
160 | 159 |
return outFeats; |
161 | 160 |
} |
162 |
|
|
163 |
|
|
161 |
|
|
164 | 162 |
/** |
165 | 163 |
* |
166 | 164 |
* @param feat |
... | ... | |
187 | 185 |
|
188 | 186 |
return res; |
189 | 187 |
} |
190 |
|
|
191 |
|
|
188 |
|
|
192 | 189 |
/** |
193 | 190 |
* |
194 | 191 |
* @param number |
... | ... | |
201 | 198 |
int ini = Math.abs(number - first); |
202 | 199 |
return (ini * 100) / total; |
203 | 200 |
} |
204 |
|
|
205 | 201 |
|
206 |
|
|
207 | 202 |
} |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/styles/Composed.java | ||
---|---|---|
32 | 32 |
import java.util.Set; |
33 | 33 |
import java.util.TreeSet; |
34 | 34 |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
36 | 35 |
import org.gvsig.geocoding.Address; |
37 | 36 |
import org.gvsig.geocoding.Literal; |
37 |
import org.gvsig.geocoding.geommatches.MatcherUtils; |
|
38 | 38 |
import org.gvsig.geocoding.result.DissolveResult; |
39 | 39 |
import org.gvsig.geocoding.result.GeocodingResult; |
40 |
import org.gvsig.geocoding.result.GeomMatchResult; |
|
40 | 41 |
import org.gvsig.geocoding.result.ScoredFeature; |
41 | 42 |
|
42 | 43 |
/** |
... | ... | |
46 | 47 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a> |
47 | 48 |
*/ |
48 | 49 |
|
49 |
public class Composed extends Simple {
|
|
50 |
public class Composed extends AbstractGeocodingStyle {
|
|
50 | 51 |
|
51 | 52 |
private List<Literal> intersectsLiterals; |
52 | 53 |
|
... | ... | |
67 | 68 |
} |
68 | 69 |
|
69 | 70 |
@Override |
70 |
public Set<GeocodingResult> match(List list, Address address) { |
|
71 |
Set<GeocodingResult> geocoRes = new TreeSet<GeocodingResult>(); |
|
72 |
List<List<DissolveResult>> secondDissolList = new ArrayList<List<DissolveResult>>(); |
|
71 |
public Set<GeocodingResult> match(List listLists, Address address) { |
|
73 | 72 |
|
74 |
// catch the first element of the main Literal to get the field |
|
75 |
// descriptor |
|
76 |
// to make the dissolve |
|
77 |
FeatureAttributeDescriptor desc = (FeatureAttributeDescriptor) style |
|
78 |
.getMainLiteral().get(0).getValue(); |
|
79 |
// dissolve features selected |
|
80 |
List<DissolveResult> disRes = style.dissolveScoredFeatures(desc, |
|
81 |
sresults); |
|
82 |
for (List<ScoredFeature> secondList : secondRes) { |
|
83 |
List<DissolveResult> secRes = style.dissolveScoredFeatures(desc, |
|
84 |
secondList); |
|
85 |
secondDissolList.add(secRes); |
|
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 |
} |
|
86 | 89 |
} |
87 |
// intersect geometrie of the list |
|
88 |
// TODO |
|
89 |
return geocoRes; |
|
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; |
|
90 | 131 |
} |
91 | 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 |
|
|
92 | 200 |
} |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/styles/AbstractRange.java | ||
---|---|---|
25 | 25 |
* 2008 PRODEVELOP Main development |
26 | 26 |
*/ |
27 | 27 |
|
28 |
|
|
29 | 28 |
package org.gvsig.geocoding.styles; |
30 | 29 |
|
31 |
import java.util.List; |
|
32 |
import java.util.Set; |
|
33 | 30 |
|
34 |
import org.gvsig.geocoding.Address; |
|
35 |
import org.gvsig.geocoding.result.GeocodingResult; |
|
36 |
|
|
37 | 31 |
/** |
38 | 32 |
* |
39 | 33 |
* |
... | ... | |
43 | 37 |
|
44 | 38 |
public abstract class AbstractRange extends AbstractGeocodingStyle { |
45 | 39 |
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 | 40 |
} |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/styles/SimpleCentroid.java | ||
---|---|---|
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.HashMap; |
|
32 |
import java.util.Iterator; |
|
33 |
import java.util.List; |
|
34 |
import java.util.Map; |
|
35 |
import java.util.Set; |
|
36 |
import java.util.TreeSet; |
|
37 |
|
|
38 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
39 |
import org.gvsig.fmap.geom.Geometry; |
|
40 |
import org.gvsig.fmap.geom.primitive.Point2D; |
|
41 |
import org.gvsig.geocoding.Address; |
|
42 |
import org.gvsig.geocoding.geommatches.MatcherUtils; |
|
43 |
import org.gvsig.geocoding.result.DissolveResult; |
|
44 |
import org.gvsig.geocoding.result.GeocodingResult; |
|
45 |
import org.gvsig.geocoding.result.GeomMatchResult; |
|
46 |
import org.gvsig.geocoding.result.ScoredFeature; |
|
47 |
|
|
48 |
/** |
|
49 |
* |
|
50 |
* |
|
51 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a> |
|
52 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a> |
|
53 |
*/ |
|
54 |
|
|
55 |
public class SimpleCentroid extends AbstractGeocodingStyle { |
|
56 |
|
|
57 |
@Override |
|
58 |
public Set<GeocodingResult> match(List inFeats, Address address) { |
|
59 |
|
|
60 |
Set<GeocodingResult> geocoRes = new TreeSet<GeocodingResult>(); |
|
61 |
|
|
62 |
// catch the first element of the main Literal to get the field |
|
63 |
// descriptor |
|
64 |
// to make the dissolve |
|
65 |
FeatureAttributeDescriptor desc = (FeatureAttributeDescriptor) this |
|
66 |
.getMainLiteral().get(0).getValue(); |
|
67 |
|
|
68 |
// POINTs FEATURES |
|
69 |
if (((ScoredFeature) inFeats.get(0)).getDefaultGeometry() |
|
70 |
.getDimension() == 0) { |
|
71 |
geocoRes = createPointsFeaturesResult(inFeats); |
|
72 |
} |
|
73 |
// OTHER GEOMETRIES TYPES |
|
74 |
else { |
|
75 |
// dissolve features selected |
|
76 |
List<DissolveResult> disRes = this.dissolveScoredFeatures(desc, |
|
77 |
inFeats); |
|
78 |
|
|
79 |
for (DissolveResult dis : disRes) { |
|
80 |
GeomMatchResult matchres = new GeomMatchResult(); |
|
81 |
Point2D position = null; |
|
82 |
|
|
83 |
Geometry geom = dis.getGeom(); |
|
84 |
// Points |
|
85 |
if (geom.getDimension() == 0) { |
|
86 |
// TODO faltan los puntos |
|
87 |
} |
|
88 |
// Lines |
|
89 |
if (geom.getDimension() == 1) { |
|
90 |
com.vividsolutions.jts.geom.Geometry geoJTS = MatcherUtils |
|
91 |
.parseGeomGVToJTS(geom); |
|
92 |
position = MatcherUtils |
|
93 |
.getLinePositionFromRelativeDistance(geoJTS, 50); |
|
94 |
} |
|
95 |
// Polys |
|
96 |
if (geom.getDimension() == 2) { |
|
97 |
position = MatcherUtils.internalPointGeometry(geom); |
|
98 |
} |
|
99 |
matchres.setGeom(position); |
|
100 |
matchres.setSources(dis.getScoredFeatures()); |
|
101 |
geocoRes.add(matchres); |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
return geocoRes; |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* |
|
110 |
* @param inFeats |
|
111 |
* @return |
|
112 |
*/ |
|
113 |
private Set<GeocodingResult> createPointsFeaturesResult( |
|
114 |
List<ScoredFeature> inFeats) { |
|
115 |
|
|
116 |
Set<GeocodingResult> results = new TreeSet<GeocodingResult>(); |
|
117 |
|
|
118 |
for (ScoredFeature feat : inFeats) { |
|
119 |
GeomMatchResult res = new GeomMatchResult(); |
|
120 |
res.setGeom(feat.getDefaultGeometry()); |
|
121 |
List<ScoredFeature> sources = new ArrayList<ScoredFeature>(); |
|
122 |
sources.add(feat); |
|
123 |
res.setSources(sources); |
|
124 |
results.add(res); |
|
125 |
} |
|
126 |
return results; |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* Dissolve features geometry behind one folder |
|
131 |
* |
|
132 |
* @param field |
|
133 |
* @param features |
|
134 |
*/ |
|
135 |
public List<DissolveResult> dissolveScoredFeatures( |
|
136 |
FeatureAttributeDescriptor field, List<ScoredFeature> features) { |
|
137 |
|
|
138 |
List<DissolveResult> listResults = new ArrayList<DissolveResult>(); |
|
139 |
|
|
140 |
// Group geometries by main attribute |
|
141 |
HashMap<String, List<ScoredFeature>> dissolAttributes = MatcherUtils |
|
142 |
.groupScoredFeaturesByAttribute(field, features); |
|
143 |
|
|
144 |
// For each group of features, to do geometries dissolve process getting |
|
145 |
// at the end one o more geometries |
|
146 |
for (Iterator<Map.Entry<String, List<ScoredFeature>>> iterator = dissolAttributes |
|
147 |
.entrySet().iterator(); iterator.hasNext();) { |
|
148 |
Map.Entry<String, List<ScoredFeature>> e = iterator.next(); |
|
149 |
List<ScoredFeature> feats = e.getValue(); |
|
150 |
|
|
151 |
// dissolve Lines (if first geometry of array is Line) |
|
152 |
List<DissolveResult> geomsDissol = null; |
|
153 |
if (feats.get(0).getDefaultGeometry().getDimension() == 1) { |
|
154 |
geomsDissol = MatcherUtils.dissolveLinesJTS(feats); |
|
155 |
} |
|
156 |
// dissolve Polys (if first geometry of array is Poly) |
|
157 |
if (feats.get(0).getDefaultGeometry().getDimension() == 2) { |
|
158 |
geomsDissol = MatcherUtils.dissolvePolysJTS(feats); |
|
159 |
} |
|
160 |
// insert each dissolve result in the general array |
|
161 |
for (DissolveResult dissolveResult : geomsDissol) { |
|
162 |
listResults.add(dissolveResult); |
|
163 |
} |
|
164 |
} |
|
165 |
return listResults; |
|
166 |
} |
|
167 |
|
|
168 |
} |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/Geocoder.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.geocoding; |
29 | 29 |
|
30 |
import java.util.List; |
|
31 | 30 |
import java.util.Set; |
32 | 31 |
|
33 | 32 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
44 | 43 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a> |
45 | 44 |
* |
46 | 45 |
*/ |
47 |
public interface Geocoder {
|
|
46 |
public interface Geocoder { |
|
48 | 47 |
|
49 |
public Set<GeocodingResult> geocode(Address address) throws InitializeException, LocatorException, DataException; |
|
48 |
public Set<GeocodingResult> geocode(Address address) |
|
49 |
throws InitializeException, LocatorException, DataException; |
|
50 | 50 |
|
51 | 51 |
} |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/distance/LevenshteinDistance.java | ||
---|---|---|
29 | 29 |
|
30 | 30 |
/** |
31 | 31 |
* Levenshtein Distance |
32 |
* |
|
32 | 33 |
* @author vsanjaime |
33 |
* |
|
34 |
*
|
|
34 | 35 |
*/ |
35 | 36 |
public class LevenshteinDistance { |
36 | 37 |
|
37 |
|
|
38 | 38 |
/** |
39 | 39 |
* calculate levenshtein distance between two strings |
40 |
* |
|
40 | 41 |
* @param str1 |
41 | 42 |
* @param str2 |
42 | 43 |
* @return |
... | ... | |
46 | 47 |
.toCharArray()); |
47 | 48 |
} |
48 | 49 |
|
49 |
|
|
50 | 50 |
/** |
51 | 51 |
* get levenshtein distance between two strings |
52 |
* |
|
52 | 53 |
* @param s |
53 | 54 |
* @param t |
54 | 55 |
* @return |
55 | 56 |
*/ |
56 |
public static int getLevenshteinDistance (String s, String t) { |
|
57 |
if (s == null || t == null) { |
|
58 |
throw new IllegalArgumentException("Strings must not be null"); |
|
59 |
} |
|
60 |
|
|
61 |
/* |
|
62 |
The difference between this impl. and the previous is that, rather |
|
63 |
than creating and retaining a matrix of size s.length()+1 by t.length()+1, |
|
64 |
we maintain two single-dimensional arrays of length s.length()+1. The first, d, |
|
65 |
is the 'current working' distance array that maintains the newest distance cost |
|
66 |
counts as we iterate through the characters of String s. Each time we increment |
|
67 |
the index of String t we are comparing, d is copied to p, the second int[]. Doing so |
|
68 |
allows us to retain the previous cost counts as required by the algorithm (taking |
|
69 |
the minimum of the cost count to the left, up one, and diagonally up and to the left |
|
70 |
of the current cost count being calculated). (Note that the arrays aren't really |
|
71 |
copied anymore, just switched...this is clearly much better than cloning an array |
|
72 |
or doing a System.arraycopy() each time through the outer loop.) |
|
57 |
public static int getLevenshteinDistance(String s, String t) { |
|
58 |
if (s == null || t == null) { |
|
59 |
throw new IllegalArgumentException("Strings must not be null"); |
|
60 |
} |
|
73 | 61 |
|
74 |
Effectively, the difference between the two implementations is this one does not |
|
75 |
cause an out of memory condition when calculating the LD over two very large strings. |
|
76 |
*/ |
|
77 |
|
|
78 |
int n = s.length(); // length of s |
|
79 |
int m = t.length(); // length of t |
|
80 |
|
|
81 |
if (n == 0) { |
|
82 |
return m; |
|
83 |
} else if (m == 0) { |
|
84 |
return n; |
|
85 |
} |
|
62 |
/* |
|
63 |
* The difference between this impl. and the previous is that, rather |
|
64 |
* than creating and retaining a matrix of size s.length()+1 by |
|
65 |
* t.length()+1, we maintain two single-dimensional arrays of length |
|
66 |
* s.length()+1. The first, d, is the 'current working' distance array |
|
67 |
* that maintains the newest distance cost counts as we iterate through |
|
68 |
* the characters of String s. Each time we increment the index of |
|
69 |
* String t we are comparing, d is copied to p, the second int[]. Doing |
|
70 |
* so allows us to retain the previous cost counts as required by the |
|
71 |
* algorithm (taking the minimum of the cost count to the left, up one, |
|
72 |
* and diagonally up and to the left of the current cost count being |
|
73 |
* calculated). (Note that the arrays aren't really copied anymore, just |
|
74 |
* switched...this is clearly much better than cloning an array or doing |
|
75 |
* a System.arraycopy() each time through the outer loop.) |
|
76 |
* |
|
77 |
* Effectively, the difference between the two implementations is this |
|
78 |
* one does not cause an out of memory condition when calculating the LD |
|
79 |
* over two very large strings. |
|
80 |
*/ |
|
86 | 81 |
|
87 |
int p[] = new int[n+1]; //'previous' cost array, horizontally |
|
88 |
int d[] = new int[n+1]; // cost array, horizontally |
|
89 |
int _d[]; //placeholder to assist in swapping p and d |
|
82 |
int n = s.length(); // length of s |
|
83 |
int m = t.length(); // length of t |
|
90 | 84 |
|
91 |
// indexes into strings s and t |
|
92 |
int i; // iterates through s |
|
93 |
int j; // iterates through t |
|
85 |
if (n == 0) { |
|
86 |
return m; |
|
87 |
} else if (m == 0) { |
|
88 |
return n; |
|
89 |
} |
|
94 | 90 |
|
95 |
char t_j; // jth character of t |
|
91 |
int p[] = new int[n + 1]; // 'previous' cost array, horizontally |
|
92 |
int d[] = new int[n + 1]; // cost array, horizontally |
|
93 |
int _d[]; // placeholder to assist in swapping p and d |
|
96 | 94 |
|
97 |
int cost; // cost |
|
95 |
// indexes into strings s and t |
|
96 |
int i; // iterates through s |
|
97 |
int j; // iterates through t |
|
98 | 98 |
|
99 |
for (i = 0; i<=n; i++) { |
|
100 |
p[i] = i; |
|
101 |
} |
|
102 |
|
|
103 |
for (j = 1; j<=m; j++) { |
|
104 |
t_j = t.charAt(j-1); |
|
105 |
d[0] = j; |
|
106 |
|
|
107 |
for (i=1; i<=n; i++) { |
|
108 |
cost = s.charAt(i-1)==t_j ? 0 : 1; |
|
109 |
// minimum of cell to the left+1, to the top+1, diagonally left and up +cost |
|
110 |
d[i] = Math.min(Math.min(d[i-1]+1, p[i]+1), p[i-1]+cost); |
|
111 |
} |
|
99 |
char t_j; // jth character of t |
|
112 | 100 |
|
113 |
// copy current distance counts to 'previous row' distance counts |
|
114 |
_d = p; |
|
115 |
p = d; |
|
116 |
d = _d; |
|
117 |
} |
|
118 |
|
|
119 |
// our last action in the above loop was to switch d and p, so p now |
|
120 |
// actually has the most recent cost counts |
|
121 |
return p[n]; |
|
101 |
int cost; // cost |
|
102 |
|
|
103 |
for (i = 0; i <= n; i++) { |
|
104 |
p[i] = i; |
|
122 | 105 |
} |
123 |
|
|
106 |
|
|
107 |
for (j = 1; j <= m; j++) { |
|
108 |
t_j = t.charAt(j - 1); |
|
109 |
d[0] = j; |
|
110 |
|
|
111 |
for (i = 1; i <= n; i++) { |
|
112 |
cost = s.charAt(i - 1) == t_j ? 0 : 1; |
|
113 |
// minimum of cell to the left+1, to the top+1, diagonally left |
|
114 |
// and up +cost |
|
115 |
d[i] = Math.min(Math.min(d[i - 1] + 1, p[i] + 1), p[i - 1] |
|
116 |
+ cost); |
|
117 |
} |
|
118 |
|
|
119 |
// copy current distance counts to 'previous row' distance counts |
|
120 |
_d = p; |
|
121 |
p = d; |
|
122 |
d = _d; |
|
123 |
} |
|
124 |
|
|
125 |
// our last action in the above loop was to switch d and p, so p now |
|
126 |
// actually has the most recent cost counts |
|
127 |
return p[n]; |
|
128 |
} |
|
129 |
|
|
124 | 130 |
/** |
125 | 131 |
* |
126 | 132 |
* @param a |
... | ... | |
135 | 141 |
return b; |
136 | 142 |
return c; |
137 | 143 |
} |
138 |
|
|
144 |
|
|
139 | 145 |
/** |
140 | 146 |
* calculate levenshtein distance between two chars |
147 |
* |
|
141 | 148 |
* @param str1 |
142 | 149 |
* @param str2 |
143 | 150 |
* @return |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/ComposeAddress.java | ||
---|---|---|
40 | 40 |
|
41 | 41 |
public class ComposeAddress extends Address { |
42 | 42 |
|
43 |
|
|
43 |
private List<Literal> intersectionLiteral = new ArrayList<Literal>(); |
|
44 | 44 |
|
45 |
private List<Literal> intersectionLiteral = new ArrayList<Literal>(); |
|
46 |
|
|
47 | 45 |
/** |
48 | 46 |
* Constructor with main literal |
47 |
* |
|
49 | 48 |
* @param main |
50 | 49 |
*/ |
51 | 50 |
public ComposeAddress(Literal main) { |
52 | 51 |
super(main); |
53 | 52 |
} |
54 |
|
|
53 |
|
|
55 | 54 |
/** |
56 | 55 |
* Constructor with intersect literals |
56 |
* |
|
57 | 57 |
* @param main |
58 | 58 |
* @param intersectionListLiterals |
59 | 59 |
*/ |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/Literal.java | ||
---|---|---|
30 | 30 |
import java.util.ArrayList; |
31 | 31 |
import java.util.Map; |
32 | 32 |
|
33 |
|
|
34 | 33 |
/** |
35 | 34 |
* Class Literal, this class has the main address components of one address |
36 | 35 |
* |
... | ... | |
40 | 39 |
public class Literal extends ArrayList<Map.Entry<String, Object>> { |
41 | 40 |
|
42 | 41 |
private static final long serialVersionUID = 1L; |
43 |
|
|
44 | 42 |
|
45 | 43 |
} |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/geommatches/DoubleCrossLineMatcher.java | ||
---|---|---|
77 | 77 |
} |
78 | 78 |
// Group second features collection by one field |
79 | 79 |
HashMap geomstreets2 = groupFeaturesByAttribute(this |
80 |
.getGroupFieldPosition(), (List) this |
|
81 |
.getFeatures().get(1)); |
|
80 |
.getGroupFieldPosition(), (List) this.getFeatures().get(1)); |
|
82 | 81 |
List streets2 = new ArrayList(); |
83 | 82 |
Iterator it2 = geomstreets2.entrySet().iterator(); |
84 | 83 |
while (it2.hasNext()) { |
... | ... | |
98 | 97 |
} |
99 | 98 |
// Group third features collection |
100 | 99 |
HashMap ppalstreets = groupFeaturesByAttribute(this |
101 |
.getGroupFieldPosition(), (List) this |
|
102 |
.getFeatures().get(2)); |
|
100 |
.getGroupFieldPosition(), (List) this.getFeatures().get(2)); |
|
103 | 101 |
List streets3 = new ArrayList(); |
104 | 102 |
Iterator it3 = ppalstreets.entrySet().iterator(); |
105 | 103 |
while (it3.hasNext()) { |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/geommatches/CrossLineMatcher.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.geocoding.geommatches; |
29 | 29 |
|
30 |
|
|
31 | 30 |
import java.util.ArrayList; |
32 | 31 |
import java.util.HashMap; |
33 | 32 |
import java.util.HashSet; |
... | ... | |
63 | 62 |
|
64 | 63 |
// Group first features collection by one field |
65 | 64 |
HashMap geomstreets1 = groupFeaturesByAttribute(this |
66 |
.getGroupFieldPosition(), (List) this |
|
67 |
.getFeatures().get(0)); |
|
65 |
.getGroupFieldPosition(), (List) this.getFeatures().get(0)); |
|
68 | 66 |
List streets1 = new ArrayList(); |
69 | 67 |
Iterator itt1 = geomstreets1.entrySet().iterator(); |
70 | 68 |
while (itt1.hasNext()) { |
... | ... | |
85 | 83 |
|
86 | 84 |
// Group second features collection by one field |
87 | 85 |
HashMap geomstreets2 = groupFeaturesByAttribute(this |
88 |
.getGroupFieldPosition(), (List) this |
|
89 |
.getFeatures().get(1)); |
|
86 |
.getGroupFieldPosition(), (List) this.getFeatures().get(1)); |
|
90 | 87 |
List streets2 = new ArrayList(); |
91 | 88 |
Iterator itt2 = geomstreets2.entrySet().iterator(); |
92 | 89 |
while (itt2.hasNext()) { |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/geommatches/SimpleLineMatcher.java | ||
---|---|---|
63 | 63 |
|
64 | 64 |
// Group the geometries by one field |
65 | 65 |
HashMap geomstreets1 = groupFeaturesByAttribute(this |
66 |
.getGroupFieldPosition(), (List) this |
|
67 |
.getFeatures().get(0)); |
|
66 |
.getGroupFieldPosition(), (List) this.getFeatures().get(0)); |
|
68 | 67 |
Iterator it = geomstreets1.entrySet().iterator(); |
69 | 68 |
Point2D[] points = new Point2D[geomstreets1.size()]; |
70 | 69 |
int position = 0; |
... | ... | |
107 | 106 |
|
108 | 107 |
double totaldistance = geometryJts.getLength(); |
109 | 108 |
LengthIndexedLine lenline = new LengthIndexedLine(geometryJts); |
110 |
|
|
109 |
|
|
111 | 110 |
Long distance = params.getDistance(); |
112 | 111 |
Integer relativedist = params.getRelativeDistance(); |
113 | 112 |
Double offset = params.getOffset(); |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/geommatches/MatchesParams.java | ||
---|---|---|
45 | 45 |
|
46 | 46 |
private static final String RELATIVEDIST = "RELATIVEDIST"; |
47 | 47 |
private static final String DISTANCE = "DISTANCE"; |
48 |
private static final String OFFSET = "OFFSET";
|
|
48 |
private static final String OFFSET = "OFFSET"; |
|
49 | 49 |
|
50 | 50 |
/** |
51 | 51 |
* Constructor class |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/geommatches/GeomMatcher.java | ||
---|---|---|
147 | 147 |
} |
148 | 148 |
|
149 | 149 |
} catch (Exception e) { |
150 |
log.debug("Error parsing geometries to JTS",e); |
|
150 |
log.debug("Error parsing geometries to JTS", e);
|
|
151 | 151 |
} |
152 | 152 |
log.debug("Geometry parsed"); |
153 | 153 |
return geomsjts; |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/pattern/Patterngeocoding.java | ||
---|---|---|
56 | 56 |
private static final String PATTERNNAME = "patternname"; |
57 | 57 |
private static final String SOURCE = "source"; |
58 | 58 |
private static final String SETTINGS = "settings"; |
59 |
|
|
59 |
|
|
60 | 60 |
private String name; |
61 | 61 |
private Settings settings; |
62 | 62 |
private GeocodingSource source; |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/pattern/GeocodingSource.java | ||
---|---|---|
52 | 52 |
/** |
53 | 53 |
* default constructor |
54 | 54 |
*/ |
55 |
public GeocodingSource(){ |
|
56 |
|
|
55 |
public GeocodingSource() {
|
|
56 |
|
|
57 | 57 |
} |
58 |
|
|
58 |
|
|
59 | 59 |
/** |
60 | 60 |
* constructor with parameters |
61 |
* |
|
61 | 62 |
* @param _style |
62 | 63 |
* @param _layerSource |
63 | 64 |
*/ |
branches/v2_0_0_prep/libraries/libGeocoding/src/org/gvsig/geocoding/pattern/Settings.java | ||
---|---|---|
38 | 38 |
* This class is one of the elements that define address pattern |
39 | 39 |
*/ |
40 | 40 |
public class Settings implements Persistent { |
41 |
|
|
41 |
|
|
42 | 42 |
private static final String ACCURACY = "accuracy"; |
43 | 43 |
private static final String RESULTSNUMBER = "resultsnumber"; |
44 | 44 |
private static final String QUALITY = "quality"; |
Also available in: Unified diff