Changeset 28018 in osm
- Timestamp:
- 2012-03-09T01:06:18+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/opendata
- Files:
-
- 128 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/build.xml
r28017 r28018 295 295 <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist"> 296 296 </target> 297 298 <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask"> 299 <classpath> 300 <fileset dir="C:\Windows\SysWOW64\jaxb-ri-20120218\lib" includes="*.jar" /> 301 </classpath> 302 </taskdef> 303 <target name="xjc_neptune"> 304 <xjc schema="resources/neptune/neptune.xsd" destdir="includes" package="neptune" target="2.1" /> 305 </target> 297 306 </project> -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/ToulouseConstants.java
r28000 r28018 40 40 public static final String ICON_CROIX_16 = "data.fr.toulouse_16.png"; 41 41 public static final String ICON_CROIX_24 = "data.fr.toulouse_24.png"; 42 43 /** 44 * NEPTUNE XML Schema modified to accept Tisséo files 45 */ 46 public static final String TOULOUSE_NEPTUNE_XSD = "/neptune_toulouse/neptune.xsd"; 42 47 } -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/ToulouseModule.java
r28000 r28018 47 47 import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.datasets.transport.PistesCyclablesHandler; 48 48 import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.datasets.transport.ReseauTisseoHandler; 49 import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.datasets.transport.TisseoHandler; 49 50 import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.datasets.transport.TramwayStationHandler; 50 51 import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.datasets.transport.VeloToulouseHandler; … … 95 96 handlers.add(new EquipementCulturelBalmaHandler()); 96 97 handlers.add(new InstallationSportiveBalmaHandler()); 98 handlers.add(new TisseoHandler()); 97 99 } 98 100 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/OdPlugin.java
r28000 r28018 30 30 import org.openstreetmap.josm.plugins.opendata.core.gui.OdPreferenceSetting; 31 31 import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter; 32 import org.openstreetmap.josm.plugins.opendata.core.io.XmlImporter; 32 33 import org.openstreetmap.josm.plugins.opendata.core.io.archive.ZipImporter; 33 34 import org.openstreetmap.josm.plugins.opendata.core.io.geographic.KmlKmzImporter; … … 55 56 new CsvImporter(), new OdsImporter(), new XlsImporter(), // Tabular file formats 56 57 new KmlKmzImporter(), new ShpImporter(), new MifTabImporter(), // Geographic file formats 57 new ZipImporter() // Archive containing any of the others 58 new ZipImporter(), // Archive containing any of the others 59 new XmlImporter() // Generic importer for XML files (currently used for Neptune files) 58 60 })) { 59 ExtensionFileFilter.importers.add(importer); 61 ExtensionFileFilter.importers.add(0, importer); 60 62 } 61 63 // Load modules -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/OdConstants.java
r28001 r28018 98 98 public static final String ZIP_EXT = "zip"; 99 99 public static final String JAR_EXT = "jar"; 100 public static final String XML_EXT = "xml"; 100 101 101 102 /** … … 115 116 public static final ExtensionFileFilter KML_KMZ_FILE_FILTER = new ExtensionFileFilter(KML_EXT+","+KMZ_EXT, KMZ_EXT, tr("KML/KMZ files") + " (*."+KML_EXT+",*."+KMZ_EXT+")"); 116 117 public static final ExtensionFileFilter ZIP_FILE_FILTER = new ExtensionFileFilter(ZIP_EXT, ZIP_EXT, tr("Zip Files") + " (*."+ZIP_EXT+")"); 118 public static final ExtensionFileFilter XML_FILE_FILTER = new ExtensionFileFilter(XML_EXT, XML_EXT, tr("OpenData XML files") + " (*."+XML_EXT+")"); 117 119 118 120 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/AbstractDataSetHandler.java
r28000 r28018 58 58 59 59 public abstract class AbstractDataSetHandler implements OdConstants { 60 60 61 public abstract boolean acceptsFilename(String filename); 62 63 public boolean acceptsFile(File file) { 64 return acceptsFilename(file.getName()); 65 } 66 61 67 public abstract void updateDataSet(DataSet ds); 62 68 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/fr/FrenchConstants.java
r28000 r28018 29 29 */ 30 30 public static final String ICON_FR_24 = "fr24.png"; 31 32 /** 33 * NEPTUNE XML Schema 34 */ 35 public static final String NEPTUNE_XSD = "/neptune/neptune.xsd"; 31 36 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/fr/FrenchDataSetHandler.java
r28000 r28018 18 18 import static org.openstreetmap.josm.plugins.opendata.core.io.LambertCC9ZonesProjectionPatterns.lambertCC9Zones; 19 19 20 import java.io.File; 21 import java.io.IOException; 20 22 import java.net.MalformedURLException; 21 23 import java.net.URL; … … 24 26 import java.util.regex.Matcher; 25 27 import java.util.regex.Pattern; 28 29 import javax.xml.XMLConstants; 30 import javax.xml.transform.Source; 31 import javax.xml.transform.stream.StreamSource; 32 import javax.xml.validation.Schema; 33 import javax.xml.validation.SchemaFactory; 34 import javax.xml.validation.Validator; 26 35 27 36 import org.geotools.referencing.CRS; … … 38 47 import org.openstreetmap.josm.data.projection.UTM.Hemisphere; 39 48 import org.openstreetmap.josm.plugins.opendata.core.datasets.SimpleDataSetHandler; 49 import org.xml.sax.SAXException; 40 50 41 51 public abstract class FrenchDataSetHandler extends SimpleDataSetHandler implements FrenchConstants { … … 273 283 } 274 284 } 285 286 protected URL getNeptuneSchema() { 287 return FrenchDataSetHandler.class.getResource(NEPTUNE_XSD); 288 } 289 290 protected final boolean acceptsXmlNeptuneFile(File file) { 291 292 Source xmlFile = new StreamSource(file); 293 294 try { 295 SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); 296 Schema schema = schemaFactory.newSchema(getNeptuneSchema()); 297 Validator validator = schema.newValidator(); 298 validator.validate(xmlFile); 299 System.out.println(xmlFile.getSystemId() + " is valid"); 300 return true; 301 } catch (SAXException e) { 302 System.out.println(xmlFile.getSystemId() + " is NOT valid"); 303 System.out.println("Reason: " + e.getLocalizedMessage()); 304 } catch (IOException e) { 305 System.out.println(xmlFile.getSystemId() + " is NOT valid"); 306 System.out.println("Reason: " + e.getLocalizedMessage()); 307 } 308 309 return false; 310 } 275 311 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/AbstractImporter.java
r28000 r28018 44 44 } 45 45 46 protected final AbstractDataSetHandler findDataSetHandler( String fileName) {46 protected final AbstractDataSetHandler findDataSetHandler(File file) { 47 47 for (Module module : ModuleHandler.moduleList) { 48 48 for (AbstractDataSetHandler dsh : module.getHandlers()) { 49 if (dsh.acceptsFile name(fileName)) {49 if (dsh.acceptsFile(file)) { 50 50 return dsh; 51 51 } … … 63 63 if (file != null) { 64 64 this.file = file; 65 this.handler = findDataSetHandler(file .getName());65 this.handler = findDataSetHandler(file); 66 66 } 67 67 super.importData(file, progressMonitor);
Note:
See TracChangeset
for help on using the changeset viewer.