Revision 47646
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/gml/GeometryStrategiesGML3.java | ||
---|---|---|
121 | 121 |
public Object parse(GMLHandler.Handler arg, GeometryFactory gf) throws SAXException { |
122 | 122 |
Object exterior = arg.children.get(0); |
123 | 123 |
Object interior = null; |
124 |
if(arg.children.size() > 1){ |
|
124 |
if(arg.children.size() > 1){ //FIXME: Ver si se est? cogiendo solo un agujero
|
|
125 | 125 |
interior = arg.children.get(1); |
126 | 126 |
} |
127 | 127 |
return new ImmutablePair(exterior, interior); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/gml/GMLHandler.java | ||
---|---|---|
116 | 116 |
* @throws SAXException |
117 | 117 |
*/ |
118 | 118 |
public Object create(GeometryFactory gf) throws SAXException { |
119 |
System.out.println("create "+this.strategy.getClass().getSimpleName()); |
|
119 |
// System.out.println("create "+this.strategy.getClass().getSimpleName());
|
|
120 | 120 |
return strategy.parse(this, gf); |
121 | 121 |
} |
122 | 122 |
} |
... | ... | |
212 | 212 |
*/ |
213 | 213 |
public void endElement(String uri, String localName, String qName) |
214 | 214 |
throws SAXException { |
215 |
System.out.println("endElement: "+localName +" , "+qName); |
|
215 |
// System.out.println("endElement: "+localName +" , "+qName);
|
|
216 | 216 |
Handler thisAction = (Handler) stack.pop(); |
217 | 217 |
((Handler) stack.peek()).keep(thisAction.create(gf)); |
218 | 218 |
} |
... | ... | |
222 | 222 |
*/ |
223 | 223 |
public void startElement(String uri, String localName, String qName, |
224 | 224 |
Attributes attributes) throws SAXException { |
225 |
System.out.println("startElement: "+localName +" , "+qName); |
|
225 |
// System.out.println("startElement: "+localName +" , "+qName);
|
|
226 | 226 |
// create a handler |
227 | 227 |
ParseStrategy ps = GeometryStrategies.findStrategy(uri, localName); |
228 | 228 |
if (ps == null) { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/gml/simplereaders/GMLReader.java | ||
---|---|---|
11 | 11 |
import java.nio.charset.Charset; |
12 | 12 |
import java.util.List; |
13 | 13 |
import org.apache.commons.io.FilenameUtils; |
14 |
import org.apache.commons.io.IOUtils; |
|
15 |
import org.cresques.cts.IProjection; |
|
16 |
import org.gvsig.fmap.crs.CRSFactory; |
|
14 | 17 |
import org.gvsig.fmap.dal.store.gml.virtualrows.GfsFile; |
15 | 18 |
import org.gvsig.fmap.dal.store.gml.virtualrows.XMLFileAsList; |
16 | 19 |
import org.gvsig.fmap.dal.store.simplereader.SimpleReaderStoreParameters; |
... | ... | |
48 | 51 |
gfs.save(gfsFile); |
49 | 52 |
} |
50 | 53 |
|
51 |
this.gml = new XMLFileAsList( |
|
52 |
gmlFile, |
|
53 |
gmlIdx, |
|
54 |
Charset.forName(SimpleReaderStoreParameters.getCharset(theParameters)), |
|
55 |
gfs.getBaseElementPath(), |
|
56 |
gfs.getGeometryElementPaths(), |
|
57 |
gfs.getPropertiesPaths() |
|
58 |
); |
|
54 |
this.gml = null; |
|
59 | 55 |
this.columns = -1; |
60 | 56 |
this.header = null; |
61 | 57 |
this.parameters = theParameters; |
62 | 58 |
} |
59 |
|
|
60 |
private XMLFileAsList getGml(){ |
|
61 |
if(this.gml == null){ |
|
62 |
this.gml = (XMLFileAsList) this.getVirtualRows(SimpleTaskStatus.FAKE_STATUS); |
|
63 |
} |
|
64 |
return this.gml; |
|
65 |
} |
|
63 | 66 |
|
64 | 67 |
@Override |
65 | 68 |
public String[] getHeader() throws IOException { |
66 | 69 |
if (this.header == null) { |
67 |
String[] theHeader = new String[gfs.size()]; |
|
70 |
List<String> geoms = gfs.getGeometryElementPaths(); |
|
71 |
String[] theHeader = new String[gfs.size()+(geoms==null?0:geoms.size())]; |
|
68 | 72 |
int i = 0; |
69 | 73 |
for (GfsFile.PropertyDefn item : gfs) { |
70 | 74 |
theHeader[i++] = item.getName(); |
71 | 75 |
} |
76 |
if(geoms != null) { |
|
77 |
List<String> srss = gfs.getGeometryElementSrss(); |
|
78 |
for (int j = 0; j < geoms.size(); j++) { |
|
79 |
IProjection srs = CRSFactory.getCRS(srss.get(j)); |
|
80 |
if(srs == null){ |
|
81 |
theHeader[i++] = FilenameUtils.getBaseName(geoms.get(j)); |
|
82 |
} else { |
|
83 |
theHeader[i++] = FilenameUtils.getBaseName(geoms.get(j))+"/Geometry/set/srs="+srs.getAbrev().replace(":", "@"); |
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
72 | 87 |
this.header = theHeader; |
73 | 88 |
} |
74 | 89 |
return this.header; |
... | ... | |
93 | 108 |
} |
94 | 109 |
|
95 | 110 |
public List<String> read(int rowNumber) throws IOException { |
96 |
if (rowNumber < gml.size()) {
|
|
97 |
List<String> values = gml.get(rowNumber);
|
|
111 |
if (rowNumber < this.getGml().size64()) {
|
|
112 |
List<String> values = this.getGml().get64(rowNumber);
|
|
98 | 113 |
return values; |
99 | 114 |
} |
100 | 115 |
return null; |
... | ... | |
102 | 117 |
|
103 | 118 |
@Override |
104 | 119 |
public void close() throws IOException { |
105 |
this.gml.close();
|
|
120 |
IOUtils.closeQuietly(this.gml);
|
|
106 | 121 |
this.gml = null; |
107 | 122 |
this.gfs = null; |
108 | 123 |
} |
... | ... | |
110 | 125 |
@Override |
111 | 126 |
public List<String> skip(int lines) throws IOException { |
112 | 127 |
this.currentElement += lines; |
113 |
if (this.currentElement > this.gml.size()) {
|
|
128 |
if (this.currentElement > this.getGml().size64()) {
|
|
114 | 129 |
return null; |
115 | 130 |
} |
116 | 131 |
return read(this.currentElement); |
... | ... | |
118 | 133 |
|
119 | 134 |
@Override |
120 | 135 |
public int getLine() { |
121 |
if (this.gml == null) {
|
|
136 |
if (this.getGml() == null) {
|
|
122 | 137 |
return 0; |
123 | 138 |
} |
124 | 139 |
return this.currentElement; |
... | ... | |
134 | 149 |
} |
135 | 150 |
|
136 | 151 |
@Override |
137 |
public GetItemWithSize64<List<String>> getVirtualRows(SimpleTaskStatus status) { |
|
138 |
return this.gml; |
|
152 |
public GetItemWithSize64<List<String>> getVirtualRows(SimpleTaskStatus status) { |
|
153 |
try { |
|
154 |
File gmlFile = this.parameters.getFile(); |
|
155 |
File gmlIdx = new File(FilenameUtils.removeExtension(gmlFile.getAbsolutePath()) + ".gmlidx"); |
|
156 |
|
|
157 |
XMLFileAsList x = new XMLFileAsList( |
|
158 |
gmlFile, |
|
159 |
gmlIdx, |
|
160 |
Charset.forName(SimpleReaderStoreParameters.getCharset(this.parameters)), |
|
161 |
gfs.getBaseElementPath(), |
|
162 |
gfs.getGeometryElementPaths(), |
|
163 |
gfs.getPropertiesPaths() |
|
164 |
); |
|
165 |
|
|
166 |
return x; |
|
167 |
} catch (IOException ex) { |
|
168 |
throw new RuntimeException("Can't get virtual rows", ex); |
|
169 |
} |
|
139 | 170 |
} |
140 | 171 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/gml/virtualrows/xmlinfo/XMLAttributeInfoImpl.java | ||
---|---|---|
33 | 33 |
private DataTypeDetector dataTypeDetector; |
34 | 34 |
private boolean isAttr; |
35 | 35 |
private String ns; |
36 |
private String srs; |
|
36 | 37 |
|
37 | 38 |
protected XMLAttributeInfoImpl(Locale locale) { |
38 | 39 |
this.path = null; |
... | ... | |
225 | 226 |
public boolean isAttr() { |
226 | 227 |
return this.isAttr; |
227 | 228 |
} |
229 |
|
|
230 |
public void setSrs(String value) { |
|
231 |
this.srs = value; |
|
232 |
} |
|
233 |
|
|
234 |
public String getSrs() { |
|
235 |
return srs; |
|
236 |
} |
|
228 | 237 |
|
229 | 238 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/gml/virtualrows/StructureExtractorImpl.java | ||
---|---|---|
100 | 100 |
xmlinfo.addTag(info); |
101 | 101 |
|
102 | 102 |
} |
103 |
XMLAttributeInfoImpl parentinfo = null; |
|
103 | 104 |
if( path.size()>1 ) { |
104 | 105 |
List<String> parentpath = path.subList(0, path.size()-1); |
105 | 106 |
String parentpath_s = StringUtils.join(parentpath, "/"); |
106 |
XMLAttributeInfoImpl parentinfo = xmlinfo.getTag(parentpath_s);
|
|
107 |
parentinfo = xmlinfo.getTag(parentpath_s); |
|
107 | 108 |
parentinfo.incrChildCount(localName); |
108 | 109 |
parentinfo.setLastChildID(localName, idvalue); |
109 | 110 |
} |
... | ... | |
118 | 119 |
infoChild.setIsAttr(true); |
119 | 120 |
xmlinfo.addTag(infoChild); |
120 | 121 |
} |
122 |
if(StringUtils.equalsIgnoreCase(name, "srsName")){ |
|
123 |
infoChild.setSrs(value); |
|
124 |
if(parentinfo != null){ |
|
125 |
parentinfo.setSrs(value); |
|
126 |
} |
|
127 |
} |
|
121 | 128 |
info.incrChildCount(infoChild.getName()); |
122 | 129 |
info.setLastChildID(infoChild.getName(), idvalueChild); |
123 | 130 |
infoChild.addValue(value); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/gml/virtualrows/GfsFile.java | ||
---|---|---|
20 | 20 |
import org.apache.commons.io.FilenameUtils; |
21 | 21 |
import org.apache.commons.io.IOUtils; |
22 | 22 |
import org.apache.commons.lang3.StringUtils; |
23 |
import org.gvsig.fmap.dal.store.gml.virtualrows.GfsFile.PropertyDefn; |
|
23 | 24 |
import org.gvsig.fmap.dal.store.gml.virtualrows.xmlinfo.XMLAttributeInfoImpl; |
24 | 25 |
import org.gvsig.fmap.dal.store.gml.virtualrows.xmlinfo.XMLInfoImpl; |
25 |
import org.gvsig.fmap.dal.store.gml.virtualrows.GfsFile.PropertyDefn; |
|
26 | 26 |
import org.gvsig.tools.ToolsLocator; |
27 | 27 |
import org.gvsig.tools.dataTypes.DataTypes; |
28 | 28 |
import org.gvsig.tools.dataTypes.DataTypesManager; |
... | ... | |
138 | 138 |
private String baseElementPath; |
139 | 139 |
private Map<String, PropertyDefn> properties; |
140 | 140 |
private int gmlVersion; |
141 |
private List<String> geometryElementSrss; |
|
141 | 142 |
|
142 | 143 |
public String getName() { |
143 | 144 |
return name; |
... | ... | |
147 | 148 |
this.name = name; |
148 | 149 |
} |
149 | 150 |
|
151 |
public List<String> getGeometryElementSrss() { |
|
152 |
return geometryElementSrss; |
|
153 |
} |
|
154 |
|
|
150 | 155 |
public List<String> getGeometryElementPaths() { |
151 | 156 |
return geometryElementPaths; |
152 | 157 |
} |
... | ... | |
165 | 170 |
this.geometryElementPaths.add(geometryElementPath); |
166 | 171 |
} |
167 | 172 |
|
173 |
public void addGeometryElementSrs(String geometryElementSrs) { |
|
174 |
if(StringUtils.isBlank(geometryElementSrs)){ |
|
175 |
return; |
|
176 |
} |
|
177 |
if(this.geometryElementSrss == null){ |
|
178 |
this.geometryElementSrss = new ArrayList<>(); |
|
179 |
} |
|
180 |
if(StringUtils.equalsIgnoreCase("null", geometryElementSrs)){ |
|
181 |
this.geometryElementSrss.add(null); |
|
182 |
} else { |
|
183 |
this.geometryElementSrss.add(geometryElementSrs); |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
168 | 187 |
public String getBaseElementPath() { |
169 | 188 |
return baseElementPath; |
170 | 189 |
} |
... | ... | |
198 | 217 |
return possibleMemberPath; |
199 | 218 |
} |
200 | 219 |
|
220 |
private List<String> findGeometryElementSrss(XMLInfoImpl xmlinfo, List<String> elementPaths) { |
|
221 |
List<String> result = new ArrayList<>(); |
|
222 |
for (String elementPath : elementPaths) { |
|
223 |
XMLAttributeInfoImpl x = xmlinfo.getTag(elementPath); |
|
224 |
if(x==null){ |
|
225 |
result.add(null); |
|
226 |
} else { |
|
227 |
result.add(x.getSrs()); |
|
228 |
} |
|
229 |
} |
|
230 |
return result; |
|
231 |
} |
|
232 |
|
|
201 | 233 |
private List<String> findGeometryElementPaths(XMLInfoImpl xmlinfo) { |
202 | 234 |
List<String> result = new ArrayList<>(); |
203 | 235 |
List<String> paths = new ArrayList<>(); |
... | ... | |
247 | 279 |
} |
248 | 280 |
if (p != null) { |
249 | 281 |
result.add(p); |
282 |
// tag.setSrs(nextTag.getSrs()); |
|
250 | 283 |
} |
251 | 284 |
} |
252 | 285 |
} |
... | ... | |
272 | 305 |
for (String geometryElementPath : getGeometryElementPaths()) { |
273 | 306 |
builder.append(" <GeometryElementPath>"+geometryElementPath+"</GeometryElementPath>\n"); |
274 | 307 |
} |
308 |
for (String geometryElementSrs : getGeometryElementSrss()) { |
|
309 |
builder.append(" <GeometryElementSrs>"+geometryElementSrs+"</GeometryElementSrs>\n"); |
|
310 |
} |
|
275 | 311 |
for (PropertyDefn property : properties.values()) { |
276 | 312 |
int type = property.getType(); |
277 | 313 |
String propertyType = datatypesManager.getTypeName(type); |
... | ... | |
342 | 378 |
|
343 | 379 |
this.baseElementPath = findBaseElementPath(xmlinfo); |
344 | 380 |
this.geometryElementPaths = findGeometryElementPaths(xmlinfo); |
381 |
this.geometryElementSrss = findGeometryElementSrss(xmlinfo,this.geometryElementPaths); |
|
345 | 382 |
|
346 | 383 |
removeBaseInGeometryPaths(); |
347 | 384 |
|
... | ... | |
501 | 538 |
} else if(StringUtils.equals(localName, "GeometryElementPath")){ |
502 | 539 |
String value = this.chars.toString(); |
503 | 540 |
addGeometryElementPath(value); |
541 |
} else if(StringUtils.equals(localName, "GeometryElementSrs")){ |
|
542 |
String value = this.chars.toString(); |
|
543 |
addGeometryElementSrs(value); |
|
504 | 544 |
} |
505 | 545 |
} |
506 | 546 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/gml/GMLFeatureTypeLoader.java | ||
---|---|---|
29 | 29 |
SimpleReader reader = new GMLReader(in, parameters); |
30 | 30 |
return reader; |
31 | 31 |
} |
32 |
|
|
33 |
@Override |
|
34 |
protected String[] getHeaders(SimpleReader reader) throws RuntimeException, IOException { |
|
35 |
String[] headers = super.getHeaders(reader); |
|
36 |
if(headers == null){ |
|
37 |
headers = ((GMLReader)reader).getHeader(); |
|
38 |
} |
|
39 |
return headers; |
|
40 |
} |
|
41 |
|
|
42 |
|
|
32 | 43 |
} |
Also available in: Unified diff