Changeset 28152 in osm for applications/editors/josm
- Timestamp:
- 2012-03-27T00:00:38+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/opendata
- Files:
-
- 9 added
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/build.xml
r28141 r28152 28 28 <property name="commit.message" value="Commit message"/> 29 29 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 30 <property name="plugin.main.version" value="5 068"/>30 <property name="plugin.main.version" value="5124"/> 31 31 <!-- should not be necessary to change the following properties --> 32 32 <property name="josm" location="../../core/dist/josm-custom.jar"/> -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/ParisModule.java
r28143 r28152 18 18 import org.openstreetmap.josm.plugins.opendata.core.modules.AbstractModule; 19 19 import org.openstreetmap.josm.plugins.opendata.core.modules.ModuleInformation; 20 import org.openstreetmap.josm.plugins.opendata.modules.fr.paris.datasets.environnement.ArbresRemarquablesHandler; 21 import org.openstreetmap.josm.plugins.opendata.modules.fr.paris.datasets.urbanisme.EclairagePublicHandler; 20 22 import org.openstreetmap.josm.plugins.opendata.modules.fr.paris.datasets.urbanisme.SanisettesHandler; 21 23 … … 25 27 super(info); 26 28 handlers.add(SanisettesHandler.class); 29 handlers.add(ArbresRemarquablesHandler.class); 30 //handlers.add(VolumesBatisHandler.class); // Disabled as the projection cannot be transformed 31 //handlers.add(VolumesNonBatisHandler.class); // Disabled as the projection cannot be transformed 32 //handlers.add(ElectriciteHandler.class); // Disabled (useless for OSM) 33 handlers.add(EclairagePublicHandler.class); 27 34 } 28 35 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/OdConstants.java
r28113 r28152 36 36 public static final String UTF8 = "UTF-8"; 37 37 public static final String ISO8859_15 = "ISO-8859-15"; 38 public static final String CP850 = "Cp850"; 38 39 public static final String CP1252 = "Cp1252"; 39 40 public static final String MAC_ROMAN = "MacRoman"; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/fr/FrenchShpHandler.java
r28113 r28152 17 17 18 18 import org.geotools.referencing.CRS; 19 import org.geotools.referencing.operation.projection.LambertConformal2SP; 20 import org.geotools.referencing.operation.projection.MapProjection.AbstractProvider; 19 21 import org.opengis.referencing.FactoryException; 20 22 import org.opengis.referencing.crs.CoordinateReferenceSystem; 23 import org.opengis.referencing.crs.ProjectedCRS; 24 import org.opengis.referencing.datum.GeodeticDatum; 21 25 import org.opengis.referencing.operation.MathTransform; 22 26 import org.openstreetmap.josm.plugins.opendata.core.io.geographic.DefaultShpHandler; … … 34 38 } else if (sourceCRS.getName().getCode().equalsIgnoreCase("RGFG95_UTM_Zone_22N")) { 35 39 return CRS.findMathTransform(CRS.decode("EPSG:2972"), targetCRS, lenient); 36 } else { 37 return super.findMathTransform(sourceCRS, targetCRS, lenient); 40 } else if (sourceCRS.getName().getCode().equalsIgnoreCase("Lambert I Nord")) { 41 if (sourceCRS instanceof ProjectedCRS) { 42 GeodeticDatum datum = ((ProjectedCRS) sourceCRS).getDatum(); 43 if (datum.getPrimeMeridian().getGreenwichLongitude() > 0.0 && ((ProjectedCRS) sourceCRS).getConversionFromBase().getMathTransform() instanceof LambertConformal2SP) { 44 LambertConformal2SP lambert = (LambertConformal2SP) ((ProjectedCRS) sourceCRS).getConversionFromBase().getMathTransform(); 45 Double falseNorthing = get(lambert.getParameterValues(), AbstractProvider.FALSE_NORTHING); 46 Double centralmeridian = get(lambert.getParameterValues(), AbstractProvider.CENTRAL_MERIDIAN); 47 if (centralmeridian.equals(0.0)) { 48 if (falseNorthing.equals(200000.0)) { 49 return CRS.findMathTransform(CRS.decode("EPSG:27561"), targetCRS, lenient); 50 } else if (falseNorthing.equals(1200000.0)) { 51 return CRS.findMathTransform(CRS.decode("EPSG:27571"), targetCRS, lenient); 52 } 53 } 54 } 55 } 38 56 } 57 return super.findMathTransform(sourceCRS, targetCRS, lenient); 39 58 } 40 59 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/NetworkReader.java
r28142 r28152 125 125 public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException { 126 126 InputStream in = null; 127 progressMonitor.beginTask(tr("Contacting Server...", 10));127 ProgressMonitor instance = null; 128 128 try { 129 .createSubTaskMonitor(9, false));129 in = getInputStreamRaw(url, progressMonitor); 130 130 if (in == null) 131 131 return null; 132 132 progressMonitor.subTask(tr("Downloading data...")); 133 ProgressMonitor instance = progressMonitor.createSubTaskMonitor(1, false);134 133 if (readerClass == null) { 135 134 readerClass = findReaderByAttachment(); … … 146 145 filename = url.substring(url.lastIndexOf('/')+1); 147 146 } 147 instance = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false); 148 148 if (readerClass.equals(ZipReader.class)) { 149 149 ZipReader zipReader = new ZipReader(in, handler); … … 177 177 throw new OsmTransferException(e); 178 178 } finally { 179 if (instance != null) { 180 instance.finishTask(); 181 } 179 182 progressMonitor.finishTask(); 180 183 try { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ZipReader.java
r28113 r28152 16 16 package org.openstreetmap.josm.plugins.opendata.core.io.archive; 17 17 18 import static org.openstreetmap.josm.tools.I18n.tr; 19 18 20 import java.io.File; 19 21 import java.io.FileInputStream; … … 89 91 } 90 92 91 public DataSet parseDoc(ProgressMonitor instance) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException {93 public DataSet parseDoc(ProgressMonitor progressMonitor) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 92 94 93 95 final File temp = createTempDir(); … … 95 97 96 98 try { 99 if (progressMonitor != null) { 100 progressMonitor.beginTask(tr("Reading Zip file...")); 101 } 97 102 ZipEntry entry; 98 103 while ((entry = zis.getNextEntry()) != null) { … … 150 155 151 156 if (candidates.size() > 1) { 152 CandidateChooser dialog = (CandidateChooser) new CandidateChooser( instance.getWindowParent(), candidates).showDialog();157 CandidateChooser dialog = (CandidateChooser) new CandidateChooser(progressMonitor.getWindowParent(), candidates).showDialog(); 153 158 if (dialog.getValue() != 1) { 154 159 return null; // User clicked Cancel … … 162 167 DataSet from = null; 163 168 FileInputStream in = new FileInputStream(file); 169 ProgressMonitor instance = null; 170 if (progressMonitor != null) { 171 instance = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false); 172 } 164 173 if (file.getName().toLowerCase().endsWith(CSV_EXT)) { 165 174 from = CsvReader.parseDataSet(in, handler, instance); … … 189 198 } 190 199 if (from != null) { 191 ds.mergeFrom(from); 200 if (progressMonitor != null) { 201 instance.finishTask(); 202 } 203 ds = from; 192 204 } 193 205 } … … 196 208 } finally { 197 209 deleteDir(temp); 210 if (progressMonitor != null) { 211 progressMonitor.finishTask(); 212 } 198 213 } 199 214 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/DefaultShpHandler.java
r28113 r28152 16 16 package org.openstreetmap.josm.plugins.opendata.core.io.geographic; 17 17 18 import java.nio.charset.Charset; 18 19 import java.util.ArrayList; 19 20 import java.util.List; 21 import java.util.Set; 20 22 21 23 import org.geotools.referencing.CRS; … … 34 36 import org.opengis.referencing.operation.MathTransform; 35 37 import org.openstreetmap.josm.Main; 38 import org.openstreetmap.josm.data.osm.DataSet; 39 import org.openstreetmap.josm.data.osm.OsmPrimitive; 36 40 import org.openstreetmap.josm.data.projection.AbstractProjection; 37 41 import org.openstreetmap.josm.data.projection.Ellipsoid; … … 54 58 } 55 59 56 pr ivatestatic final Double get(ParameterValueGroup values, ParameterDescriptor desc) {60 protected static final Double get(ParameterValueGroup values, ParameterDescriptor desc) { 57 61 return (Double) values.parameter(desc.getName().getCode()).getValue(); 58 62 } … … 66 70 } 67 71 72 private boolean useNodeMap = true; 68 73 private boolean checkNodeProximity = false; 69 74 private boolean preferMultipolygonToSimpleWay = false; 75 private Charset dbfCharset = null; 70 76 71 77 @Override … … 151 157 checkNodeProximity = check; 152 158 } 159 160 @Override 161 public void setUseNodeMap(boolean use) { 162 useNodeMap = use; 163 } 164 165 @Override 166 public boolean useNodeMap() { 167 return useNodeMap; 168 } 169 170 @Override 171 public void notifyFeatureParsed(Object feature, DataSet result, Set<OsmPrimitive> featurePrimitives) { 172 // To be overriden by modules handlers 173 } 174 175 @Override 176 public void setDbfCharset(Charset charset) { 177 dbfCharset = charset; 178 } 179 180 @Override 181 public Charset getDbfCharset() { 182 return dbfCharset; 183 } 153 184 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpHandler.java
r28113 r28152 16 16 package org.openstreetmap.josm.plugins.opendata.core.io.geographic; 17 17 18 import java.nio.charset.Charset; 19 import java.util.Set; 20 18 21 import org.opengis.referencing.FactoryException; 19 22 import org.opengis.referencing.crs.CoordinateReferenceSystem; 20 23 import org.opengis.referencing.operation.MathTransform; 24 import org.openstreetmap.josm.data.osm.DataSet; 25 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 26 22 27 public interface ShpHandler { … … 31 36 32 37 public boolean checkNodeProximity(); 38 39 public void setUseNodeMap(boolean use); 40 41 public boolean useNodeMap(); 42 43 public void notifyFeatureParsed(Object feature, DataSet result, Set<OsmPrimitive> featurePrimitives); 44 45 public void setDbfCharset(Charset charset); 46 47 public Charset getDbfCharset(); 33 48 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpReader.java
r28113 r28152 25 25 import java.util.ArrayList; 26 26 import java.util.HashMap; 27 import java.util.HashSet; 27 28 import java.util.List; 28 29 import java.util.Map; 30 import java.util.Set; 29 31 30 32 import javax.swing.Icon; … … 32 34 import javax.swing.JOptionPane; 33 35 36 import org.geotools.data.DataStore; 34 37 import org.geotools.data.FeatureSource; 35 import org.geotools.data.FileDataStore; 36 import org.geotools.data.FileDataStoreFinder; 38 import org.geotools.data.shapefile.ShapefileDataStoreFactory; 37 39 import org.geotools.factory.Hints; 38 40 import org.geotools.feature.FeatureCollection; … … 61 63 import org.opengis.referencing.operation.TransformException; 62 64 import org.openstreetmap.josm.Main; 63 import org.openstreetmap.josm. data.coor.EastNorth;65 import org.openstreetmap.josm.corrector.UserCancelException; 64 66 import org.openstreetmap.josm.data.coor.LatLon; 65 67 import org.openstreetmap.josm.data.osm.DataSet; … … 89 91 private final Map<String, Node> nodes; 90 92 91 private DataSet result;92 93 private CoordinateReferenceSystem crs; 93 94 private MathTransform transform; 95 96 private final Set<OsmPrimitive> featurePrimitives = new HashSet<OsmPrimitive>(); 94 97 95 98 public ShpReader(ShpHandler handler) throws NoSuchAuthorityCodeException, FactoryException { … … 162 165 return result; 163 166 } 167 168 private void findCrsAndMathTransform(CoordinateReferenceSystem coordinateReferenceSystem, Component parent) throws FactoryException, UserCancelException, ShpMathTransformException { 169 crs = coordinateReferenceSystem; 170 try { 171 transform = CRS.findMathTransform(crs, wgs84); 172 } catch (OperationNotFoundException e) { 173 System.out.println(crs.getName()+": "+e.getMessage()); // Bursa wolf parameters required. 174 175 List<CoordinateReferenceSystem> candidates = new ArrayList<CoordinateReferenceSystem>(); 176 177 // Find matching CRS with Bursa Wolf parameters in EPSG database 178 for (String code : CRS.getAuthorityFactory(false).getAuthorityCodes(ProjectedCRS.class)) { 179 CoordinateReferenceSystem candidate = CRS.decode(code); 180 if (candidate instanceof AbstractCRS && crs instanceof AbstractIdentifiedObject) { 181 182 Hints.putSystemDefault(Hints.COMPARISON_TOLERANCE, 183 Main.pref.getDouble(PREF_CRS_COMPARISON_TOLERANCE, DEFAULT_CRS_COMPARISON_TOLERANCE)); 184 if (((AbstractCRS)candidate).equals((AbstractIdentifiedObject)crs, false)) { 185 System.out.println("Found a potential CRS: "+candidate.getName()); 186 candidates.add(candidate); 187 } else if (Main.pref.getBoolean(PREF_CRS_COMPARISON_DEBUG, false)) { 188 compareDebug(crs, candidate); 189 } 190 Hints.removeSystemDefault(Hints.COMPARISON_TOLERANCE); 191 } 192 } 193 194 if (candidates.size() > 1) { 195 System.err.println("Found several potential CRS.");//TODO: ask user which one to use 196 } 197 198 if (candidates.size() > 0) { 199 CoordinateReferenceSystem newCRS = candidates.get(0); 200 try { 201 transform = CRS.findMathTransform(newCRS, wgs84, false); 202 } catch (OperationNotFoundException ex) { 203 System.err.println(newCRS.getName()+": "+e.getMessage()); 204 } 205 } 206 207 if (transform == null) { 208 if (handler != null) { 209 // ask handler if it can provide a math transform 210 transform = handler.findMathTransform(crs, wgs84, false); 211 } 212 if (transform == null) { 213 // ask user before trying lenient method 214 if (warnLenientMethod(parent, crs)) { 215 // User canceled 216 throw new UserCancelException(); 217 } 218 System.out.println("Searching for a lenient math transform."); 219 transform = CRS.findMathTransform(crs, wgs84, true); 220 } 221 } 222 } 223 if (transform == null) { 224 throw new ShpMathTransformException("Unable to find math transform !"); 225 } 226 } 227 228 private void parseFeature(Feature feature, Component parent) 229 throws UserCancelException, ShpMathTransformException, FactoryException, ShpCrsException, MismatchedDimensionException, TransformException { 230 featurePrimitives.clear(); 231 GeometryAttribute geometry = feature.getDefaultGeometryProperty(); 232 if (geometry != null) { 233 234 GeometryDescriptor desc = geometry.getDescriptor(); 235 236 if (crs == null && desc != null && desc.getCoordinateReferenceSystem() != null) { 237 findCrsAndMathTransform(desc.getCoordinateReferenceSystem(), parent); 238 } else if (crs == null) { 239 throw new ShpCrsException("Unable to detect CRS !"); 240 } 241 242 OsmPrimitive primitive = null; 243 244 if (geometry.getValue() instanceof Point) { 245 primitive = createOrGetNode((Point) geometry.getValue()); 246 247 } else if (geometry.getValue() instanceof GeometryCollection) { // Deals with both MultiLineString and MultiPolygon 248 GeometryCollection mp = (GeometryCollection) geometry.getValue(); 249 int nGeometries = mp.getNumGeometries(); 250 if (nGeometries < 1) { 251 System.err.println("Error: empty geometry collection found"); 252 } else { 253 Relation r = null; 254 Way w = null; 255 256 for (int i=0; i<nGeometries; i++) { 257 Geometry g = mp.getGeometryN(i); 258 if (g instanceof Polygon) { 259 Polygon p = (Polygon) g; 260 // Do not create relation if there's only one polygon without interior ring 261 // except if handler prefers it 262 if (r == null && (nGeometries > 1 || p.getNumInteriorRing() > 0 || (handler != null && handler.preferMultipolygonToSimpleWay()))) { 263 r = createMultipolygon(); 264 } 265 w = createWay(p.getExteriorRing()); 266 if (r != null) { 267 addWayToMp(r, "outer", w); 268 for (int j=0; j<p.getNumInteriorRing(); j++) { 269 addWayToMp(r, "inner", createWay(p.getInteriorRingN(j))); 270 } 271 } 272 } else if (g instanceof LineString) { 273 w = createWay((LineString) g); 274 } else if (g instanceof Point) { 275 // Some belgian data sets hold points into collections ?! 276 readNonGeometricAttributes(feature, createOrGetNode((Point) g)); 277 } else { 278 System.err.println("Error: unsupported geometry : "+g); 279 } 280 } 281 primitive = r != null ? r : w; 282 } 283 } else { 284 // Debug unknown geometry 285 System.out.println("\ttype: "+geometry.getType()); 286 System.out.println("\tbounds: "+geometry.getBounds()); 287 System.out.println("\tdescriptor: "+desc); 288 System.out.println("\tname: "+geometry.getName()); 289 System.out.println("\tvalue: "+geometry.getValue()); 290 System.out.println("\tid: "+geometry.getIdentifier()); 291 System.out.println("-------------------------------------------------------------"); 292 } 293 294 if (primitive != null) { 295 // Read primitive non geometric attributes 296 readNonGeometricAttributes(feature, primitive); 297 } 298 } 299 } 164 300 165 301 public DataSet parse(File file, ProgressMonitor instance) throws IOException { 166 result = null;167 302 crs = null; 168 303 transform = null; 169 304 try { 170 305 if (file != null) { 171 FileDataStore dataStore = FileDataStoreFinder.getDataStore(file); 306 Map params = new HashMap(); 307 params.put(ShapefileDataStoreFactory.URLP.key, file.toURI().toURL()); 308 if (handler != null && handler.getDbfCharset() != null) { 309 params.put(ShapefileDataStoreFactory.DBFCHARSET.key, handler.getDbfCharset()); 310 } 311 DataStore dataStore = new ShapefileDataStoreFactory().createDataStore(params);//FIXME 172 312 if (dataStore == null) { 173 313 throw new IOException(tr("Unable to find a data store for file {0}", file.getName())); … … 180 320 FeatureCollection<?,?> collection = featureSource.getFeatures(); 181 321 FeatureIterator<?> iterator = collection.features(); 182 183 result = new DataSet(); 322 323 if (instance != null) { 324 instance.beginTask(tr("Loading shapefile ({0} features)", collection.size()), collection.size()); 325 } 326 327 int n = 0; 328 329 Component parent = instance != null ? instance.getWindowParent() : Main.parent; 184 330 185 331 try { 186 332 while (iterator.hasNext()) { 187 Feature feature = iterator.next(); 188 GeometryAttribute geometry = feature.getDefaultGeometryProperty(); 189 if (geometry != null) { 190 191 GeometryDescriptor desc = geometry.getDescriptor(); 192 193 if (crs == null && desc != null && desc.getCoordinateReferenceSystem() != null) { 194 crs = desc.getCoordinateReferenceSystem(); 195 try { 196 transform = CRS.findMathTransform(crs, wgs84); 197 } catch (OperationNotFoundException e) { 198 System.out.println(crs.getName()+": "+e.getMessage()); // Bursa wolf parameters required. 199 200 List<CoordinateReferenceSystem> candidates = new ArrayList<CoordinateReferenceSystem>(); 201 202 // Find matching CRS with Bursa Wolf parameters in EPSG database 203 for (String code : CRS.getAuthorityFactory(false).getAuthorityCodes(ProjectedCRS.class)) { 204 CoordinateReferenceSystem candidate = CRS.decode(code); 205 if (candidate instanceof AbstractCRS && crs instanceof AbstractIdentifiedObject) { 206 207 Hints.putSystemDefault(Hints.COMPARISON_TOLERANCE, 208 Main.pref.getDouble(PREF_CRS_COMPARISON_TOLERANCE, DEFAULT_CRS_COMPARISON_TOLERANCE)); 209 if (((AbstractCRS)candidate).equals((AbstractIdentifiedObject)crs, false)) { 210 System.out.println("Found a potential CRS: "+candidate.getName()); 211 candidates.add(candidate); 212 } else if (Main.pref.getBoolean(PREF_CRS_COMPARISON_DEBUG, false)) { 213 compareDebug(crs, candidate); 214 } 215 Hints.removeSystemDefault(Hints.COMPARISON_TOLERANCE); 216 } 217 } 218 219 if (candidates.size() > 1) { 220 System.err.println("Found several potential CRS.");//TODO: ask user which one to use 221 } 222 223 if (candidates.size() > 0) { 224 CoordinateReferenceSystem newCRS = candidates.get(0); 225 try { 226 transform = CRS.findMathTransform(newCRS, wgs84, false); 227 } catch (OperationNotFoundException ex) { 228 System.err.println(newCRS.getName()+": "+e.getMessage()); 229 } 230 } 231 232 if (transform == null) { 233 if (handler != null) { 234 // ask handler if it can provide a math transform 235 transform = handler.findMathTransform(crs, wgs84, false); 236 } 237 if (transform == null) { 238 // ask user before trying lenient method 239 if (warnLenientMethod(instance.getWindowParent(), crs)) { 240 // User canceled 241 return result; 242 } 243 System.out.println("Searching for a lenient math transform."); 244 transform = CRS.findMathTransform(crs, wgs84, true); 245 } 246 } 247 } 248 if (transform == null) { 249 System.err.println("Unable to find math transform !"); 250 // TODO: something 251 return result; 252 } 253 } else if (crs == null) { 254 System.err.println("Unable to detect CRS !"); 255 // TODO: ask projection 256 return result; 333 n++; 334 try { 335 Object feature = iterator.next(); 336 parseFeature(iterator.next(), parent); 337 if (handler != null) { 338 handler.notifyFeatureParsed(feature, ds, featurePrimitives); 257 339 } 258 259 OsmPrimitive primitive = null; 260 261 if (geometry.getValue() instanceof Point) { 262 primitive = createOrGetNode((Point) geometry.getValue()); 263 264 } else if (geometry.getValue() instanceof GeometryCollection) { // Deals with both MultiLineString and MultiPolygon 265 GeometryCollection mp = (GeometryCollection) geometry.getValue(); 266 int nGeometries = mp.getNumGeometries(); 267 if (nGeometries < 1) { 268 System.err.println("Error: empty geometry collection found"); 269 } else { 270 Relation r = null; 271 Way w = null; 272 273 for (int i=0; i<nGeometries; i++) { 274 Geometry g = mp.getGeometryN(i); 275 if (g instanceof Polygon) { 276 Polygon p = (Polygon) g; 277 // Do not create relation if there's only one polygon without interior ring 278 // except if handler prefers it 279 if (r == null && (nGeometries > 1 || p.getNumInteriorRing() > 0 || (handler != null && handler.preferMultipolygonToSimpleWay()))) { 280 r = createMultipolygon(); 281 } 282 w = createWay(p.getExteriorRing()); 283 if (r != null) { 284 addWayToMp(r, "outer", w); 285 for (int j=0; j<p.getNumInteriorRing(); j++) { 286 addWayToMp(r, "inner", createWay(p.getInteriorRingN(j))); 287 } 288 } 289 } else if (g instanceof LineString) { 290 w = createWay((LineString) g); 291 } else if (g instanceof Point) { 292 // Some belgian data sets hold points into collections ?! 293 readNonGeometricAttributes(feature, createOrGetNode((Point) g)); 294 } else { 295 System.err.println("Error: unsupported geometry : "+g); 296 } 297 } 298 primitive = r != null ? r : w; 299 } 300 } else { 301 // Debug unknown geometry 302 System.out.println("\ttype: "+geometry.getType()); 303 System.out.println("\tbounds: "+geometry.getBounds()); 304 System.out.println("\tdescriptor: "+desc); 305 System.out.println("\tname: "+geometry.getName()); 306 System.out.println("\tvalue: "+geometry.getValue()); 307 System.out.println("\tid: "+geometry.getIdentifier()); 308 System.out.println("-------------------------------------------------------------"); 309 } 310 311 if (primitive != null) { 312 // Read primitive non geometric attributes 313 readNonGeometricAttributes(feature, primitive); 314 } 340 } catch (UserCancelException e) { 341 return ds; 342 } 343 if (instance != null) { 344 instance.worked(1); 345 instance.setCustomText(n+"/"+collection.size()); 315 346 } 316 347 } … … 318 349 iterator.close(); 319 350 nodes.clear(); 351 if (instance != null) { 352 instance.setCustomText(null); 353 } 320 354 } 321 355 } … … 325 359 throw new IOException(t); 326 360 } 327 return result;361 return ds; 328 362 } 329 363 … … 385 419 386 420 private Node createOrGetNode(Point p) throws MismatchedDimensionException, TransformException { 387 if (transform != null) { 388 Point p2 = (Point) JTS.transform(p, transform); 389 String key = p2.getX()+"/"+p2.getY(); 390 //String key = LatLon.roundToOsmPrecisionStrict(p2.getX())+"/"+LatLon.roundToOsmPrecisionStrict(p2.getY()); 391 Node n = getNode(p2, key); 392 if (n == null) { 393 nodes.put(key, n = new Node(new LatLon(p2.getY(), p2.getX()))); 394 result.addPrimitive(n); 395 } 396 return n; 397 } else { 398 EastNorth en = new EastNorth(p.getX(), p.getY()); 399 // TODO: something to transform coordinates 400 return new Node(en); 401 } 421 Point p2 = (Point) JTS.transform(p, transform); 422 String key = p2.getX()+"/"+p2.getY(); 423 //String key = LatLon.roundToOsmPrecisionStrict(p2.getX())+"/"+LatLon.roundToOsmPrecisionStrict(p2.getY()); 424 Node n = getNode(p2, key); 425 if (n == null) { 426 n = new Node(new LatLon(p2.getY(), p2.getX())); 427 if (handler == null || handler.useNodeMap()) { 428 nodes.put(key, n); 429 } 430 ds.addPrimitive(n); 431 } else if (n.getDataSet() == null) { 432 // ShpHandler may have removed the node from DataSet (see Paris public light handler for example) 433 ds.addPrimitive(n); 434 } 435 featurePrimitives.add(n); 436 return n; 402 437 } 403 438 … … 413 448 } 414 449 } 415 result.addPrimitive(w); 416 return w; 450 return addOsmPrimitive(w); 417 451 } 418 452 … … 420 454 Relation r = new Relation(); 421 455 r.put("type", "multipolygon"); 422 result.addPrimitive(r); 423 return r; 456 return addOsmPrimitive(r); 424 457 } 425 458 … … 428 461 r.addMember(new RelationMember(role, w)); 429 462 } 463 464 private <T extends OsmPrimitive> T addOsmPrimitive(T p) { 465 ds.addPrimitive(p); 466 featurePrimitives.add(p); 467 return p; 468 } 430 469 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/TabReader.java
r28113 r28152 112 112 try { 113 113 File dataFile = getDataFile(file, ".dat"); 114 ds .mergeFrom(new TabOsmReader(handler != null ? handler.getSpreadSheetHandler() : null, new TabFiles(file, dataFile)).115 doParse(columns.toArray(new String[0]), instance) );114 ds = new TabOsmReader(handler != null ? handler.getSpreadSheetHandler() : null, new TabFiles(file, dataFile)). 115 doParse(columns.toArray(new String[0]), instance); 116 116 } catch (IOException e) { 117 117 System.err.println(e.getMessage());
Note:
See TracChangeset
for help on using the changeset viewer.