Changeset 36176 in osm for applications/editors/josm/plugins
- Timestamp:
- 2023-10-19T21:58:56+02:00 (13 months ago)
- Location:
- applications/editors/josm/plugins
- Files:
-
- 2 added
- 6 deleted
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageLayer.java
r36013 r36176 20 20 21 21 import org.geotools.coverage.grid.GridCoverage2D; 22 import org.geotools.geometry. Envelope2D;22 import org.geotools.geometry.jts.ReferencedEnvelope; 23 23 import org.geotools.image.ImageWorker; 24 24 import org.geotools.referencing.CRS; 25 import org. opengis.referencing.FactoryException;26 import org. opengis.referencing.crs.CoordinateReferenceSystem;25 import org.geotools.api.referencing.FactoryException; 26 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 27 27 import org.openstreetmap.josm.actions.RenameLayerAction; 28 28 import org.openstreetmap.josm.data.Bounds; … … 57 57 58 58 // current bbox 59 private Envelope2Dbbox;59 private ReferencedEnvelope bbox; 60 60 61 61 // Layer icon … … 144 144 Logging.debug("ImportImagePlugin ImageLayer: Coverage created: {0}", coverage); 145 145 146 upperLeft = new EastNorth(coverage.getEnvelope2D(). x,147 coverage.getEnvelope2D(). y + coverage.getEnvelope2D().height);146 upperLeft = new EastNorth(coverage.getEnvelope2D().getMinX(), 147 coverage.getEnvelope2D().getMaxY()); 148 148 angle = 0; 149 149 bbox = coverage.getEnvelope2D(); … … 230 230 } 231 231 232 public Envelope2DgetBbox() {232 public ReferencedEnvelope getBbox() { 233 233 return bbox; 234 234 } … … 301 301 this.image = ((PlanarImage) coverage.getRenderedImage()).getAsBufferedImage(); 302 302 303 upperLeft = new EastNorth(coverage.getEnvelope2D().x, coverage 304 .getEnvelope2D().y 305 + coverage.getEnvelope2D().height); 303 upperLeft = new EastNorth(coverage.getEnvelope2D().getMinX(), coverage.getEnvelope2D().getMaxY()); 306 304 angle = 0; 307 305 -
applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/LayerPropertiesDialog.java
r36013 r36176 31 31 32 32 import org.geotools.referencing.CRS; 33 import org. opengis.referencing.FactoryException;34 import org. opengis.referencing.crs.CoordinateReferenceSystem;33 import org.geotools.api.referencing.FactoryException; 34 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 35 35 import org.openstreetmap.josm.tools.Logging; 36 36 -
applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/PluginOperations.java
r36013 r36176 2 2 package org.openstreetmap.josm.plugins.ImportImagePlugin; 3 3 4 import java.awt.geom.Rectangle2D;5 4 import java.awt.image.BufferedImage; 6 5 import java.io.BufferedReader; … … 17 16 import javax.imageio.ImageIO; 18 17 18 import org.geotools.api.data.DataSourceException; 19 import org.geotools.api.parameter.ParameterValueGroup; 20 import org.geotools.api.referencing.FactoryException; 21 import org.geotools.api.referencing.crs.CRSAuthorityFactory; 22 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 23 import org.geotools.api.util.InternationalString; 19 24 import org.geotools.coverage.grid.GridCoverage2D; 20 25 import org.geotools.coverage.grid.GridCoverageFactory; 21 26 import org.geotools.coverage.processing.CoverageProcessor; 22 import org.geotools.data.DataSourceException;23 27 import org.geotools.data.WorldFileReader; 24 28 import org.geotools.gce.geotiff.GeoTiffReader; 25 import org.geotools.geometry. Envelope2D;29 import org.geotools.geometry.jts.ReferencedEnvelope; 26 30 import org.geotools.referencing.CRS; 27 31 import org.geotools.util.factory.Hints; 28 import org.opengis.parameter.ParameterValueGroup;29 import org.opengis.referencing.FactoryException;30 import org.opengis.referencing.crs.CRSAuthorityFactory;31 import org.opengis.referencing.crs.CoordinateReferenceSystem;32 import org.opengis.util.InternationalString;33 32 import org.openstreetmap.josm.tools.Logging; 34 33 … … 153 152 double lowerLeft_x = tfwReader.getXULC(); 154 153 double lowerLeft_y = tfwReader.getYULC() - height; 155 Envelope2D bbox = new Envelope2D(null, new Rectangle2D.Double(lowerLeft_x, lowerLeft_y, width, height));154 ReferencedEnvelope bbox = ReferencedEnvelope.rect(lowerLeft_x, lowerLeft_y, width, height, null); 156 155 coverage = createGridCoverage(img, bbox, refSys); 157 156 … … 185 184 double lowerLeft_x = tfwReader.getXULC(); 186 185 double lowerLeft_y = tfwReader.getYULC() - height; 187 Envelope2D bbox = new Envelope2D(null, new Rectangle2D.Double(lowerLeft_x, lowerLeft_y, width, height));186 ReferencedEnvelope bbox = ReferencedEnvelope.rect(lowerLeft_x, lowerLeft_y, width, height, null); 188 187 coverage = createGridCoverage(img, bbox, refSys); 189 188 … … 216 215 double lowerLeft_x = tfwReader.getXULC(); 217 216 double lowerLeft_y = tfwReader.getYULC() - height; 218 Envelope2D bbox = new Envelope2D(null, new Rectangle2D.Double(lowerLeft_x, lowerLeft_y, width, height));217 ReferencedEnvelope bbox = ReferencedEnvelope.rect(lowerLeft_x, lowerLeft_y, width, height, null); 219 218 coverage = createGridCoverage(img, bbox, refSys); 220 219 … … 248 247 double lowerLeft_x = tfwReader.getXULC(); 249 248 double lowerLeft_y = tfwReader.getYULC() - height; 250 Envelope2D bbox = new Envelope2D(null, new Rectangle2D.Double(lowerLeft_x, lowerLeft_y, width, height));249 ReferencedEnvelope bbox = ReferencedEnvelope.rect(lowerLeft_x, lowerLeft_y, width, height, null); 251 250 coverage = createGridCoverage(img, bbox, refSys); 252 251 … … 293 292 * Method for external use. 294 293 */ 295 public static GridCoverage2D createGridCoverage(BufferedImage img, Envelope2Dbbox, CoordinateReferenceSystem crs) {294 public static GridCoverage2D createGridCoverage(BufferedImage img, ReferencedEnvelope bbox, CoordinateReferenceSystem crs) { 296 295 bbox.setCoordinateReferenceSystem(crs); 297 296 return new GridCoverageFactory().create("", img, bbox); -
applications/editors/josm/plugins/MicrosoftStreetside/ivy.xml
r36034 r36176 2 2 <ivy-module xmlns:m="http://ant.apache.org/ivy/maven" version="2.0"> 3 3 <info organisation="org.openstreetmap.josm.plugins" module="MicrosoftStreetside" revision="0.0.1"/> 4 <configurations defaultconf="default" defaultconfmapping="default- >default">4 <configurations defaultconf="default" defaultconfmapping="default->default"> 5 5 <conf name="default"/> 6 6 <conf name="provided" description="Needed for compile, but will be present at runtime"/> 7 7 </configurations> 8 8 <dependencies> 9 <dependency org="com.fasterxml.jackson.core" name="jackson-annotations" rev="2.1 2.4" conf="default->default"/>10 <dependency org="com.fasterxml.jackson.core" name="jackson-databind" rev="2.1 2.4" conf="default->default"/>11 <dependency org="us.monoid.web" name="resty" rev="0.3.2" conf="default- >default"/>9 <dependency org="com.fasterxml.jackson.core" name="jackson-annotations" rev="2.15.3" conf="default->default"/> 10 <dependency org="com.fasterxml.jackson.core" name="jackson-databind" rev="2.15.3" conf="default->default"/> 11 <dependency org="us.monoid.web" name="resty" rev="0.3.2" conf="default->default"/> 12 12 <dependency org="org.openjfx" name="javafx-swing" rev="19" conf="provided"> 13 13 <artifact name="javafx-swing" type="jar" m:classifier="linux"/> -
applications/editors/josm/plugins/OsmInspectorPlugin/build.xml
r34538 r36176 13 13 <!--<property name="plugin.link" value=""/>--> 14 14 <property name="plugin.requires" value="jts;geotools"/> 15 <property name="plugin.minimum.java.version" value="11"/> 15 16 16 17 <!-- ** include targets that all plugins have in common ** --> 17 18 <import file="../build-common.xml"/> 18 19 19 <fileset id="plugin.requires.jars" dir="${plugin.dist.dir}"> 20 <target name="pre-compile" depends="fetch_dependencies"> 21 <!-- include fetch_dependencies task --> 22 </target> 23 24 <fileset id="plugin.requires.jars" dir="${plugin.dist.dir}"> 20 25 <include name="jts.jar"/> 21 26 <include name="geotools.jar"/> -
applications/editors/josm/plugins/OsmInspectorPlugin/src/org/openstreetmap/josm/plugins/osminspector/GeoFabrikWFSClient.java
r35123 r36176 8 8 import javax.swing.ProgressMonitor; 9 9 10 import org.geotools. data.DataStore;11 import org.geotools. data.DataStoreFinder;12 import org.geotools. data.FeatureSource;10 import org.geotools.api.data.DataStore; 11 import org.geotools.api.data.DataStoreFinder; 12 import org.geotools.api.data.FeatureSource; 13 13 import org.geotools.factory.CommonFactoryFinder; 14 14 import org.geotools.feature.FeatureCollection; 15 15 import org.geotools.geometry.jts.ReferencedEnvelope; 16 16 import org.geotools.referencing.CRS; 17 import org. opengis.feature.simple.SimpleFeature;18 import org. opengis.feature.simple.SimpleFeatureType;19 import org. opengis.feature.type.AttributeDescriptor;20 import org. opengis.filter.Filter;21 import org. opengis.filter.FilterFactory2;22 import org. opengis.referencing.FactoryException;23 import org. opengis.referencing.NoSuchAuthorityCodeException;24 import org. opengis.referencing.crs.CoordinateReferenceSystem;17 import org.geotools.api.feature.simple.SimpleFeature; 18 import org.geotools.api.feature.simple.SimpleFeatureType; 19 import org.geotools.api.feature.type.AttributeDescriptor; 20 import org.geotools.api.filter.Filter; 21 import org.geotools.api.filter.FilterFactory; 22 import org.geotools.api.referencing.FactoryException; 23 import org.geotools.api.referencing.NoSuchAuthorityCodeException; 24 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 25 25 import org.openstreetmap.josm.data.Bounds; 26 26 import org.openstreetmap.josm.data.coor.LatLon; … … 30 30 public class GeoFabrikWFSClient { 31 31 32 33 34 private boolean bInitialized = false;32 //private Bounds bbox; 33 private DataStore data; 34 private boolean bInitialized; 35 35 36 37 38 36 public GeoFabrikWFSClient(Bounds bounds) { 37 //bbox = bounds; 38 } 39 39 40 41 42 40 public FeatureCollection<SimpleFeatureType, SimpleFeature> getFeatures( 41 String typeName, ProgressMonitor progressMonitor) 42 throws IOException, NoSuchAuthorityCodeException, FactoryException { 43 43 44 44 initializeDataStore(); 45 45 46 // Step 3 - discovery; enhance to iterate over all types with bounds 47 SimpleFeatureType schema = data.getSchema(typeName); 48 progressMonitor.setProgress(30); 49 50 // Step 4 - target 51 FeatureSource<SimpleFeatureType, SimpleFeature> source = data 52 .getFeatureSource(typeName); 53 Logging.info("Source Metadata Bounds:" + source.getBounds()); 54 Logging.info("Source schema: " + source.getSchema()); 46 // Step 3 - discovery; enhance to iterate over all types with bounds 47 SimpleFeatureType schema = data.getSchema(typeName); 48 progressMonitor.setProgress(30); 55 49 56 progressMonitor.setProgress(40); 57 58 // Step 5 - query 59 List<AttributeDescriptor> listAttrs = schema.getAttributeDescriptors(); 60 String geomName = listAttrs.get(0).getLocalName(); 61 CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4236"); 50 // Step 4 - target 51 FeatureSource<SimpleFeatureType, SimpleFeature> source = data 52 .getFeatureSource(typeName); 53 Logging.info("Source Metadata Bounds:" + source.getBounds()); 54 Logging.info("Source schema: " + source.getSchema()); 62 55 63 Bounds bounds = MainApplication.getMap().mapView.getLatLonBounds( 64 MainApplication.getMap().mapView.getBounds()); 56 progressMonitor.setProgress(40); 65 57 66 LatLon minLL = bounds.getMin(); 67 LatLon maxLL = bounds.getMax(); 68 double minLat = Math.min(minLL.getY(), maxLL.getY()); 69 double maxLat = Math.max(minLL.getY(), maxLL.getY()); 70 double minLon = Math.min(minLL.getX(), maxLL.getX()); 71 double maxLon = Math.max(minLL.getX(), maxLL.getX()); 58 // Step 5 - query 59 List<AttributeDescriptor> listAttrs = schema.getAttributeDescriptors(); 60 String geomName = listAttrs.get(0).getLocalName(); 61 CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4236"); 72 62 73 ReferencedEnvelope bboxRef = new ReferencedEnvelope(minLon, maxLon, 74 minLat, maxLat, targetCRS); 75 Logging.info("Reference Bounds:" + bboxRef); 63 Bounds bounds = MainApplication.getMap().mapView.getLatLonBounds( 64 MainApplication.getMap().mapView.getBounds()); 76 65 77 progressMonitor.setProgress(50); 78 // 79 // Ask WFS service for typeName data constrained by bboxRef 80 // 81 FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(); 82 Filter filterBB = ff.bbox(ff.property(geomName), bboxRef); 83 FeatureCollection<SimpleFeatureType, SimpleFeature> features = source 84 .getFeatures(filterBB); 66 LatLon minLL = bounds.getMin(); 67 LatLon maxLL = bounds.getMax(); 68 double minLat = Math.min(minLL.getY(), maxLL.getY()); 69 double maxLat = Math.max(minLL.getY(), maxLL.getY()); 70 double minLon = Math.min(minLL.getX(), maxLL.getX()); 71 double maxLon = Math.max(minLL.getX(), maxLL.getX()); 85 72 86 progressMonitor.setProgress(80); 87 return features;88 } 73 ReferencedEnvelope bboxRef = new ReferencedEnvelope(minLon, maxLon, 74 minLat, maxLat, targetCRS); 75 Logging.info("Reference Bounds:" + bboxRef); 89 76 90 public void initializeDataStore() throws IOException { 91 if (bInitialized == true) 92 return; 77 progressMonitor.setProgress(50); 78 // 79 // Ask WFS service for typeName data constrained by bboxRef 80 // 81 FilterFactory ff = CommonFactoryFinder.getFilterFactory(); 82 Filter filterBB = ff.bbox(ff.property(geomName), bboxRef); 83 FeatureCollection<SimpleFeatureType, SimpleFeature> features = source 84 .getFeatures(filterBB); 93 85 94 String getCapabilities = "http://tools.geofabrik.de/osmi/view/routing_non_eu/wxs?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetCapabilities"; 95 @SuppressWarnings("rawtypes") 96 Map<String, Comparable> connectionParameters = new HashMap<>(); 97 connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL", 98 getCapabilities); 99 connectionParameters.put("WFSDataStoreFactory:WFS_STRATEGY", 100 "mapserver"); 101 connectionParameters.put("WFSDataStoreFactory:LENIENT", true); 102 connectionParameters.put("WFSDataStoreFactory:TIMEOUT", 20000); 103 connectionParameters.put("WFSDataStoreFactory:BUFFER_SIZE", 10000); 104 // Step 2 - connection 105 data = DataStoreFinder.getDataStore(connectionParameters); 86 progressMonitor.setProgress(80); 87 return features; 88 } 106 89 107 bInitialized = true; 108 } 90 public void initializeDataStore() throws IOException { 91 if (bInitialized) 92 return; 109 93 110 public String[] getTypeNames() throws IOException { 111 return data.getTypeNames(); 112 } 94 String getCapabilities = "http://tools.geofabrik.de/osmi/view/routing_non_eu/wxs?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetCapabilities"; 95 @SuppressWarnings("rawtypes") 96 Map<String, Comparable> connectionParameters = new HashMap<>(); 97 connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL", 98 getCapabilities); 99 connectionParameters.put("WFSDataStoreFactory:WFS_STRATEGY", 100 "mapserver"); 101 connectionParameters.put("WFSDataStoreFactory:LENIENT", true); 102 connectionParameters.put("WFSDataStoreFactory:TIMEOUT", 20000); 103 connectionParameters.put("WFSDataStoreFactory:BUFFER_SIZE", 10000); 104 // Step 2 - connection 105 data = DataStoreFinder.getDataStore(connectionParameters); 113 106 114 public DataStore getData() { 115 return data; 116 } 107 bInitialized = true; 108 } 117 109 118 public void setData(DataStore data) { 119 this.data = data; 120 } 110 public String[] getTypeNames() throws IOException { 111 return data.getTypeNames(); 112 } 113 114 public DataStore getData() { 115 return data; 116 } 117 118 public void setData(DataStore data) { 119 this.data = data; 120 } 121 121 } -
applications/editors/josm/plugins/OsmInspectorPlugin/src/org/openstreetmap/josm/plugins/osminspector/ImportOsmInspectorBugsAction.java
r35123 r36176 11 11 import javax.swing.ProgressMonitor; 12 12 13 import org. opengis.referencing.FactoryException;13 import org.geotools.api.referencing.FactoryException; 14 14 import org.openstreetmap.josm.actions.JosmAction; 15 15 import org.openstreetmap.josm.data.Bounds; … … 22 22 23 23 public class ImportOsmInspectorBugsAction extends JosmAction { 24 25 26 * 27 28 24 OsmInspectorPlugin plugin; 25 /** 26 * 27 */ 28 private static final long serialVersionUID = -6484182416189079287L; 29 29 30 31 32 33 34 35 36 37 30 public ImportOsmInspectorBugsAction(OsmInspectorPlugin thePlugin) { 31 super(tr("Import Osm Inspector Bugs..."), "importosmibugs", 32 tr("Import Osm Inspector Bugs..."), Shortcut.registerShortcut("importosmibugs", 33 tr("Edit: {0}", tr("Import Osm Inspector Bugs...")), 34 KeyEvent.VK_O, Shortcut.ALT_CTRL), true); 35 putValue("help", ht("/Action/ImportOsmInspectorBugs")); 36 plugin = thePlugin; 37 } 38 38 39 40 41 42 43 44 39 @Override 40 public void actionPerformed(ActionEvent event) { 41 if (isEnabled()) { 42 MapView mapView = MainApplication.getMap().mapView; 43 ProgressMonitor monitor = new ProgressMonitor(mapView, 44 "Querying WFS Geofabrik", "Dowloading features", 0, 100); 45 45 46 47 46 try { 47 Bounds bounds = mapView.getLatLonBounds(mapView.getBounds()); 48 48 49 49 Logging.info("OSMI View bounds" + bounds); 50 50 51 51 monitor.setProgress(10); 52 52 53 OsmInspectorLayer inspector = plugin.getLayer(); 54 if (inspector == null) { 55 GeoFabrikWFSClient wfs = new GeoFabrikWFSClient(bounds); 56 wfs.initializeDataStore(); 57 inspector = new OsmInspectorLayer(wfs, monitor); 58 MainApplication.getLayerManager().addLayer(inspector); 59 plugin.setLayer(inspector); 60 } else { 61 GeoFabrikWFSClient wfs = new GeoFabrikWFSClient(bounds); 62 wfs.initializeDataStore(); 63 inspector.loadFeatures(wfs); 53 OsmInspectorLayer inspector = plugin.getLayer(); 54 GeoFabrikWFSClient wfs = new GeoFabrikWFSClient(bounds); 55 wfs.initializeDataStore(); 56 if (inspector == null) { 57 inspector = new OsmInspectorLayer(wfs, monitor); 58 MainApplication.getLayerManager().addLayer(inspector); 59 plugin.setLayer(inspector); 60 } else { 61 inspector.loadFeatures(wfs); 64 62 65 66 67 68 69 70 71 72 73 74 75 76 77 63 } 64 } catch (IOException | IndexOutOfBoundsException | NoSuchElementException | FactoryException | ParseException e) { 65 Logging.error(e); 66 } finally { 67 monitor.close(); 68 if (plugin.getLayer() != null) { 69 plugin.getLayer().updateView(); 70 } 71 } 72 } else { 73 Logging.warn("Osm Inspector Action not enabled"); 74 } 75 } 78 76 79 77 } -
applications/editors/josm/plugins/OsmInspectorPlugin/src/org/openstreetmap/josm/plugins/osminspector/OSMIFeatureTracker.java
r30828 r36176 2 2 3 3 import java.util.HashMap; 4 import java.util. Iterator;4 import java.util.Map; 5 5 6 import org.geotools.api.feature.simple.SimpleFeature; 7 import org.geotools.api.feature.simple.SimpleFeatureType; 6 8 import org.geotools.data.memory.MemoryFeatureCollection; 7 9 import org.geotools.feature.FeatureCollection; 8 10 import org.geotools.feature.FeatureIterator; 9 import org.opengis.feature.simple.SimpleFeature; 10 import org.opengis.feature.simple.SimpleFeatureType; 11 import org.openstreetmap.josm.tools.Logging; 11 12 12 13 public class OSMIFeatureTracker { 13 14 14 private HashMap<Long, SimpleFeature> hashFeatures;15 privateMemoryFeatureCollection features;15 private final Map<Long, SimpleFeature> hashFeatures; 16 private final MemoryFeatureCollection features; 16 17 17 18 19 20 18 public OSMIFeatureTracker( 19 FeatureCollection<SimpleFeatureType, SimpleFeature> featuresIn) { 20 hashFeatures = new HashMap<>(); 21 features = new MemoryFeatureCollection(featuresIn.getSchema()); 21 22 22 for (Iterator<?> it = features.iterator(); it.hasNext();) { 23 SimpleFeature element = (SimpleFeature) it.next(); 24 try { 25 Long ID = (Long.parseLong((String) element 26 .getAttribute("problem_id"))); 23 for (SimpleFeature element : features) { 24 try { 25 Long id = (Long.parseLong((String) element 26 .getAttribute("problem_id"))); 27 27 28 if (!hashFeatures.containsKey(ID)) {29 hashFeatures.put(ID, element);30 31 32 33 continue;34 35 28 if (!hashFeatures.containsKey(id)) { 29 hashFeatures.put(id, element); 30 features.add(element); 31 } 32 } catch (NumberFormatException e) { 33 Logging.trace(e); 34 } 35 } 36 36 37 38 39 40 41 42 37 try (FeatureIterator<SimpleFeature> it = featuresIn.features()) { 38 while (it.hasNext()) { 39 features.add(it.next()); 40 } 41 } 42 } 43 43 44 45 46 47 48 SimpleFeature element = (SimpleFeature)it.next();49 50 Long ID= (Long.parseLong((String) element51 44 public boolean mergeFeatures( 45 FeatureCollection<SimpleFeatureType, SimpleFeature> newFeatures) { 46 try (FeatureIterator<SimpleFeature> it = newFeatures.features()) { 47 while (it.hasNext()) { 48 SimpleFeature element = it.next(); 49 try { 50 Long id = (Long.parseLong((String) element 51 .getAttribute("problem_id"))); 52 52 53 if (!hashFeatures.containsKey(ID)) {54 hashFeatures.put(ID, element);55 56 57 58 continue;59 60 61 53 if (!hashFeatures.containsKey(id)) { 54 hashFeatures.put(id, element); 55 features.add(element); 56 } 57 } catch (NumberFormatException e) { 58 Logging.trace(e); 59 } 60 } 61 } 62 62 63 64 63 return true; 64 } 65 65 66 public HashMap<Long, SimpleFeature> getFeatureHash() {67 68 66 public Map<Long, SimpleFeature> getFeatureHash() { 67 return hashFeatures; 68 } 69 69 70 71 72 70 public FeatureCollection<SimpleFeatureType, SimpleFeature> getFeatures() { 71 return features; 72 } 73 73 } -
applications/editors/josm/plugins/OsmInspectorPlugin/src/org/openstreetmap/josm/plugins/osminspector/OsmInspectorLayer.java
r35123 r36176 9 9 import java.util.HashMap; 10 10 import java.util.HashSet; 11 import java.util.Iterator;12 11 import java.util.LinkedHashMap; 12 import java.util.List; 13 13 import java.util.Map; 14 14 import java.util.Map.Entry; … … 20 20 import javax.swing.ProgressMonitor; 21 21 22 import org.geotools.api.data.SimpleFeatureSource; 23 import org.geotools.api.feature.Property; 24 import org.geotools.api.feature.simple.SimpleFeature; 25 import org.geotools.api.feature.simple.SimpleFeatureType; 26 import org.geotools.api.feature.type.Name; 27 import org.geotools.api.filter.FilterFactory; 28 import org.geotools.api.filter.identity.FeatureId; 29 import org.geotools.api.filter.spatial.Intersects; 30 import org.geotools.api.referencing.FactoryException; 31 import org.geotools.api.referencing.NoSuchAuthorityCodeException; 32 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 33 import org.geotools.api.style.FeatureTypeStyle; 34 import org.geotools.api.style.Fill; 35 import org.geotools.api.style.Graphic; 36 import org.geotools.api.style.Mark; 37 import org.geotools.api.style.Rule; 38 import org.geotools.api.style.Stroke; 39 import org.geotools.api.style.Style; 40 import org.geotools.api.style.StyleFactory; 41 import org.geotools.api.style.Symbolizer; 22 42 import org.geotools.data.DataUtilities; 23 import org.geotools.data.simple.SimpleFeatureSource;24 43 import org.geotools.factory.CommonFactoryFinder; 25 44 import org.geotools.feature.FeatureCollection; … … 30 49 import org.geotools.referencing.CRS; 31 50 import org.geotools.renderer.lite.StreamingRenderer; 32 import org.geotools.styling.FeatureTypeStyle; 33 import org.geotools.styling.Fill; 34 import org.geotools.styling.Graphic; 35 import org.geotools.styling.Mark; 36 import org.geotools.styling.Rule; 37 import org.geotools.styling.Stroke; 38 import org.geotools.styling.Style; 39 import org.geotools.styling.StyleFactory; 40 import org.geotools.styling.Symbolizer; 41 import org.opengis.feature.Property; 42 import org.opengis.feature.simple.SimpleFeature; 43 import org.opengis.feature.simple.SimpleFeatureType; 44 import org.opengis.feature.type.Name; 45 import org.opengis.filter.FilterFactory2; 46 import org.opengis.filter.identity.FeatureId; 47 import org.opengis.filter.spatial.Intersects; 48 import org.opengis.referencing.FactoryException; 49 import org.opengis.referencing.NoSuchAuthorityCodeException; 50 import org.opengis.referencing.crs.CoordinateReferenceSystem; 51 import org.locationtech.jts.geom.Envelope; 52 import org.locationtech.jts.geom.Geometry; 53 import org.locationtech.jts.io.ParseException; 51 54 import org.openstreetmap.josm.data.Bounds; 52 55 import org.openstreetmap.josm.data.coor.LatLon; … … 60 63 import org.openstreetmap.josm.tools.Logging; 61 64 62 import org.locationtech.jts.geom.Envelope;63 import org.locationtech.jts.geom.Geometry;64 import org.locationtech.jts.io.ParseException;65 66 65 public class OsmInspectorLayer extends Layer { 67 66 68 private StyleFactory sf = CommonFactoryFinder.getStyleFactory(null); 69 private FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); 70 private StreamingRenderer renderer; 71 private CoordinateReferenceSystem crsOSMI; 72 private GeomType geometryType; 73 private String geometryAttributeName; 74 75 private SimpleFeatureSource featureSource; 76 private MapContent content; 77 private boolean bIsChanged; 78 79 private int layerOffset = 1; 80 81 private ArrayList<GeomType> selectGeomType; 82 private Color[] featureFills = { new Color(255, 0, 0), 83 new Color(0, 0, 255), // duplicate ways 84 new Color(204, 204, 0), // minor 5 85 new Color(255, 230, 128), // minor 2 86 new Color(255, 204, 0), // minor 1 87 new Color(255, 102, 102), // major 5 88 new Color(255, 148, 77), // major 2 89 new Color(255, 0, 0), // major 1 90 new Color(255, 255, 64), // selected 91 new Color(255, 0, 0), new Color(255, 0, 0) }; 92 93 /** 94 * dialog showing the bug info 95 */ 96 private OsmInspectorDialog dialog; 97 98 /** 99 * supported actions 100 */ 101 102 // Container for bugs from Osmi 103 private ArrayList<OSMIFeatureTracker> arrFeatures; 104 private LinkedHashMap<BugInfo, Long> osmiBugInfo; 105 106 public Geometry getOsmBugGeometry(int index) { 107 BugInfo[] array = new BugInfo[osmiBugInfo.keySet().size()]; 108 array = osmiBugInfo.keySet().toArray(array); 109 return array[index].getGeom(); 110 } 111 112 public Map<BugInfo, Long> getOsmiBugInfo() { 113 return osmiBugInfo; 114 } 115 116 public SimpleFeatureSource getFeatureSource() { 117 return featureSource; 118 } 119 120 public void setFeatureSource(SimpleFeatureSource featureSource) { 121 this.featureSource = featureSource; 122 } 123 124 public boolean isbIsChanged() { 125 return bIsChanged; 126 } 127 128 public void setbIsChanged(boolean bIsChanged) { 129 this.bIsChanged = bIsChanged; 130 } 131 132 public ArrayList<OSMIFeatureTracker> getArrFeatures() { 133 return arrFeatures; 134 } 135 136 public void setArrFeatures(ArrayList<OSMIFeatureTracker> arrFeatures) { 137 this.arrFeatures = arrFeatures; 138 } 139 140 public BugIndex getOsmiIndex() { 141 return osmiIndex; 142 } 143 144 // Pointer to prev and next osmi bugs 145 private BugIndex osmiIndex; 146 147 /** 148 * 149 * The Bug attribute class: hold geom, id and description for that bug 150 * 151 * @author snikhil 152 * 153 */ 154 public static class BugInfo implements Comparable<BugInfo>{ 155 156 public Geometry getGeom() { 157 return geom; 158 } 159 160 public String getDesc() { 161 return desc; 162 } 163 164 public String getId() { 165 return id; 166 } 167 168 @Override 169 public int hashCode() { 170 String fid = attributes.get("FID"); 171 String hash = (fid == null || fid.isEmpty()) ? attributes.get("problem_id") : fid; 172 return hash.hashCode(); 173 } 174 175 @Override 176 public boolean equals(Object obj) { 177 String fid = attributes.get("FID"); 178 String hash = (fid == null || fid.isEmpty()) ? attributes.get("problem_id") : fid; 179 180 181 if (obj instanceof BugInfo) { 182 BugInfo b = (BugInfo) obj; 183 184 String bfid = b.attributes.get("FID"); 185 String bhash = (bfid == null || bfid.isEmpty()) ? b.attributes.get("problem_id") : bfid; 186 return hash.equals(bhash); 187 } 188 return false; 189 } 190 191 // private final long bugId; //incremental bugId 192 private final long bugId; 193 private final Geometry geom; 194 private final String desc; 195 private final String id; 196 private final Name name; 197 private final Map<String, String> attributes; 198 199 public BugInfo(SimpleFeature next, long idx) 200 throws IndexOutOfBoundsException, ParseException { 201 202 bugId = idx; 203 attributes = new HashMap<>(); 204 Collection<Property> properties = next.getProperties(); 205 Iterator<Property> it = properties.iterator(); 206 while (it.hasNext()) { 207 Property p = it.next(); 208 attributes.put(p.getName().toString(), p.getValue().toString()); 209 } 210 this.geom = (Geometry) next.getAttribute(0); 211 this.desc = (String) next.getAttribute("error_desc"); 212 this.id = next.getID(); 213 name = next.getName(); 214 } 215 216 @Override 217 public String toString() { 218 StringBuilder sb = new StringBuilder(); 219 sb.append("BugId_").append(String.valueOf(bugId)).append("\n"); 220 return sb.toString(); 221 } 222 223 public String getContentString() { 224 StringBuilder sb = new StringBuilder(); 225 sb.append("Layer:").append(name.getLocalPart()).append("\n"); 226 Iterator<Entry<String, String>> it = attributes.entrySet() 227 .iterator(); 228 while (it.hasNext()) { 229 Entry<String, String> next = it.next(); 230 sb.append(next.getKey()).append(":").append(next.getValue()) 231 .append("\n"); 232 } 233 return sb.toString(); 234 } 235 236 public long getBugId() { 237 return bugId; 238 } 239 240 @Override 241 public int compareTo(BugInfo o) { 242 String fid = attributes.get("FID"); 243 String hash = (fid == null || fid.isEmpty()) ? attributes.get("problem_id") : fid; 244 245 String ofid = o.attributes.get("FID"); 246 String ohash = (ofid == null || ofid.isEmpty()) ? o.attributes.get("problem_id") : ofid; 247 return hash.compareTo(ohash); 248 } 249 } 250 251 /** 252 * Helper class that stores the bug next and prev pointers and can navigate 253 * the entire bug list 254 * 255 * @author snikhil 256 * 257 */ 258 public static class BugIndex { 259 private int nextIndex; 260 private int previousIndex; 261 private ArrayList<BugInfo> osmBugs; 262 263 public BugIndex(Map<BugInfo, Long> bugs) { 264 osmBugs = new ArrayList<>(bugs.keySet()); 265 nextIndex = 0; 266 previousIndex = -1; 267 } 268 269 public BugIndex(Map<BugInfo, Long> bugs, int n, int p) { 270 osmBugs = new ArrayList<>(bugs.keySet()); 271 nextIndex = n; 272 previousIndex = p; 273 } 274 275 public void next() { 276 previousIndex = nextIndex; 277 nextIndex = ++nextIndex % osmBugs.size(); 278 } 279 280 public void prev() { 281 nextIndex = previousIndex; 282 previousIndex = previousIndex - 1 < 0 ? osmBugs.size() - 1 283 : --previousIndex; 284 } 285 286 public BugInfo getItemPointedByNext() { 287 return osmBugs.get(nextIndex); 288 } 289 290 public BugInfo getItemPointedByPrev() { 291 return osmBugs.get(nextIndex); 292 } 293 294 public int indexOf(BugInfo b) { 295 return osmBugs.indexOf(b); 296 } 297 298 public BugInfo getNext() { 299 next(); 300 return osmBugs.get(nextIndex); 301 } 302 303 public BugInfo getPrev() { 304 prev(); 305 return osmBugs.get(nextIndex); 306 } 307 308 public ArrayList<BugInfo> getBugs() { 309 return osmBugs; 310 } 311 312 public void append(LinkedHashMap<BugInfo, Long> osmiBugInfo) { 313 Iterator<BugInfo> it = osmiBugInfo.keySet().iterator(); 314 while(it.hasNext()){ 315 BugInfo next = it.next(); 316 if(!osmBugs.contains(next)){ 317 this.osmBugs.add(next); 318 } 319 } 320 } 321 } 322 323 private enum GeomType { 324 POINT, LINE, POLYGON 325 } 326 327 private static final Color SELECTED_COLOUR = Color.ORANGE; 328 private static final float SELECTED_POINT_SIZE = 15.0f; 329 private static final float OPACITY = 1.0f; 330 private static final float LINE_WIDTH = 1.0f; 331 private static final float POINT_SIZE = 10.0f; 332 333 public OsmInspectorLayer(GeoFabrikWFSClient wfsClient, 334 ProgressMonitor monitor) throws NoSuchAuthorityCodeException, 335 FactoryException, IOException, IndexOutOfBoundsException, 336 ParseException { 337 super("OsmInspector"); 338 339 arrFeatures = new ArrayList<>(); 340 osmiBugInfo = new LinkedHashMap<>(); 341 selectGeomType = new ArrayList<>(); 342 343 // Step 3 - discovery; enhance to iterate over all types with bounds 344 345 String typeNames[] = wfsClient.getTypeNames(); 346 renderer = new StreamingRenderer(); 347 CRS.decode(ProjectionRegistry.getProjection().toCode()); 348 crsOSMI = CRS.decode("EPSG:4326"); 349 content = new MapContent(); 350 content.getViewport().setCoordinateReferenceSystem(crsOSMI); 351 352 selectGeomType.add(GeomType.POINT); 353 for (int idx = 1; idx < typeNames.length; ++idx) { 354 String typeName = typeNames[idx]; 355 Set<FeatureId> selectedFeatures = new HashSet<>(); 356 357 FeatureCollection<SimpleFeatureType, SimpleFeature> features = wfsClient 358 .getFeatures(typeName, monitor); 359 setGeometry(selectGeomType, typeName); 360 361 Logging.info("Osm Inspector Features size: " + features.size()); 362 Style style = createDefaultStyle(idx, selectedFeatures); 363 364 OSMIFeatureTracker tracker = new OSMIFeatureTracker(features); 365 arrFeatures.add(tracker); 366 FeatureIterator<SimpleFeature> it = tracker.getFeatures().features(); 367 368 while (it.hasNext()) { 369 BugInfo theInfo = new BugInfo(it.next(), osmiBugInfo.size()); 370 osmiBugInfo.put(theInfo, theInfo.bugId); 371 } 372 373 content.addLayer(new FeatureLayer(tracker.getFeatures(), style)); 374 } 375 376 osmiIndex = new BugIndex(osmiBugInfo); 377 content.setTitle("Osm Inspector Errors"); 378 renderer.setMapContent(content); 379 bIsChanged = true; 380 381 // finally initialize the dialog 382 dialog = new OsmInspectorDialog(this); 383 this.updateView(); 384 } 385 386 public void loadFeatures(GeoFabrikWFSClient wfsClient) 387 throws NoSuchAuthorityCodeException, FactoryException, IOException, 388 IndexOutOfBoundsException, NoSuchElementException, ParseException { 389 String typeNames[] = wfsClient.getTypeNames(); 390 391 content.layers().clear(); 392 selectGeomType.clear(); 393 selectGeomType.add(GeomType.POINT); 394 395 ProgressMonitor monitor = new ProgressMonitor(MainApplication.getMap().mapView, 396 "Loading features", "", 0, 100); 397 398 for (int idx = 1; idx < typeNames.length; ++idx) { 399 String typeName = typeNames[idx]; 400 Set<FeatureId> selectedFeatures = new HashSet<>(); 401 402 monitor.setProgress(100 / typeNames.length * idx); 403 FeatureCollection<SimpleFeatureType, SimpleFeature> features = wfsClient 404 .getFeatures(typeName, monitor); 405 setGeometry(selectGeomType, typeName); 406 407 Logging.info("Osm Inspector Features size: " + features.size()); 408 409 OSMIFeatureTracker tracker = arrFeatures.get(idx - layerOffset); 410 tracker.mergeFeatures(features); 411 412 FeatureIterator<SimpleFeature> it = tracker.getFeatures().features(); 413 414 while (it.hasNext()) { 415 BugInfo theInfo = new BugInfo(it.next(), osmiBugInfo.size()); 416 if (!osmiBugInfo.keySet().contains(theInfo)) { 417 osmiBugInfo.put(theInfo, theInfo.bugId); 418 } 419 } 420 421 Style style = createDefaultStyle(idx, selectedFeatures); 422 content.addLayer(new FeatureLayer(tracker.getFeatures(), style)); 423 } 424 425 osmiIndex.append(osmiBugInfo); 426 427 428 monitor.setProgress(100); 429 monitor.close(); 430 bIsChanged = true; 431 //dialog.updateDialog(this); 432 dialog.refreshModel(); 433 //dialog.updateNextPrevAction(this); 434 435 this.updateView(); 436 } 437 438 private Style createDefaultStyle(int idx, Set<FeatureId> IDs) { 439 Color fillColor = featureFills[idx]; 440 441 Rule selectedRule = createRule(SELECTED_COLOUR, SELECTED_COLOUR, true); 442 selectedRule.setFilter(ff.id(IDs)); 443 444 Rule rule = createRule(fillColor, fillColor, false); 445 rule.setElseFilter(true); 446 447 FeatureTypeStyle fts = sf.createFeatureTypeStyle(); 448 fts.rules().add(selectedRule); 449 fts.rules().add(rule); 450 451 Style style = sf.createStyle(); 452 style.featureTypeStyles().add(fts); 453 return style; 454 } 455 456 private Rule createRule(Color outlineColor, Color fillColor, 457 boolean bSelected) { 458 Symbolizer symbolizer = null; 459 Fill fill = null; 460 Stroke stroke = sf.createStroke(ff.literal(outlineColor), 461 ff.literal(LINE_WIDTH)); 462 463 switch (geometryType) { 464 case POLYGON: 465 fill = sf.createFill(ff.literal(fillColor), ff.literal(OPACITY)); 466 symbolizer = sf.createPolygonSymbolizer(stroke, fill, 467 geometryAttributeName); 468 break; 469 470 case LINE: 471 symbolizer = sf.createLineSymbolizer(stroke, geometryAttributeName); 472 break; 473 474 case POINT: 475 fill = sf.createFill(ff.literal(fillColor), ff.literal(OPACITY)); 476 477 Mark mark = sf.getTriangleMark(); 478 mark.setFill(fill); 479 mark.setStroke(stroke); 480 481 Graphic graphic = sf.createDefaultGraphic(); 482 graphic.graphicalSymbols().clear(); 483 graphic.graphicalSymbols().add(mark); 484 graphic.setSize(ff.literal(bSelected ? SELECTED_POINT_SIZE 485 : POINT_SIZE)); 486 487 symbolizer = sf.createPointSymbolizer(graphic, 488 geometryAttributeName); 489 } 490 491 Rule rule = sf.createRule(); 492 rule.symbolizers().add(symbolizer); 493 return rule; 494 } 495 496 private void setGeometry(ArrayList<GeomType> selectedTypes, String typename) { 497 Logging.info("Passed type is" + typename); 498 if (typename.compareTo("duplicate_ways") == 0) { 499 geometryType = GeomType.LINE; 500 } else 501 geometryType = GeomType.POINT; 502 503 selectedTypes.add(geometryType); 504 } 505 506 @Override 507 public Icon getIcon() { 508 return ImageProvider.get("layer/osmdata_small"); 509 } 510 511 @Override 512 public Object getInfoComponent() { 513 return getToolTipText(); 514 } 515 516 @Override 517 public Action[] getMenuEntries() { 518 return new Action[] {}; 519 } 520 521 @Override 522 public String getToolTipText() { 523 return org.openstreetmap.josm.tools.I18n.tr("OsmInspector"); 524 } 525 526 @Override 527 public boolean isMergable(Layer other) { 528 return false; 529 } 530 531 @Override 532 public void mergeFrom(Layer from) { 533 return; 534 } 535 536 @Override 537 public void paint(Graphics2D g, MapView mv, Bounds box) { 538 LatLon min = box.getMin(); 539 LatLon max = box.getMax(); 540 541 Envelope envelope2 = new Envelope(Math.min(min.lat(), max.lat()), 542 Math.max(min.lat(), max.lat()), Math.min(min.lon(), max.lon()), 543 Math.max(min.lon(), max.lon())); 544 545 ReferencedEnvelope mapArea = new ReferencedEnvelope(envelope2, crsOSMI); 546 547 renderer.setInteractive(false); 548 renderer.paint(g, mv.getBounds(), mapArea); 549 bIsChanged = false; 550 } 551 552 @Override 553 public void visitBoundingBox(BoundingXYVisitor v) { 554 } 555 556 public boolean isChanged() { 557 return bIsChanged; 558 } 559 560 public void updateView() { 561 this.dialog.revalidate(); 562 invalidate(); 563 } 564 565 public void selectFeatures(int x, int y) { 566 int pixelDelta = 2; 567 LatLon clickUL = MainApplication.getMap().mapView.getLatLon(x - pixelDelta, y 568 - pixelDelta); 569 LatLon clickLR = MainApplication.getMap().mapView.getLatLon(x + pixelDelta, y 570 + pixelDelta); 571 572 Envelope envelope = new Envelope( 573 Math.min(clickUL.lon(), clickLR.lon()), Math.max(clickUL.lon(), 574 clickLR.lon()), Math.min(clickUL.lat(), clickLR.lat()), 575 Math.max(clickUL.lat(), clickLR.lat())); 576 577 ReferencedEnvelope mapArea = new ReferencedEnvelope(envelope, crsOSMI); 578 579 Intersects filter = ff.intersects(ff.property("msGeometry"), 580 ff.literal(mapArea)); 581 // 582 // Select features in all layers 583 // 584 content.layers().clear(); 585 586 // Iterate through features and build a list that intersects the above 587 // envelope 588 for (int idx = 0; idx < arrFeatures.size(); ++idx) { 589 OSMIFeatureTracker tracker = arrFeatures.get(idx); 590 FeatureCollection<SimpleFeatureType, SimpleFeature> features = tracker 591 .getFeatures(); 592 593 SimpleFeatureSource tempfs = DataUtilities.source(features); 594 FeatureCollection<SimpleFeatureType, SimpleFeature> selectedFeatures; 595 596 try { 597 selectedFeatures = tempfs.getFeatures(filter); 67 private final StyleFactory sf = CommonFactoryFinder.getStyleFactory(null); 68 private final FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); 69 private final StreamingRenderer renderer; 70 private final CoordinateReferenceSystem crsOSMI; 71 private GeomType geometryType; 72 private String geometryAttributeName; 73 74 private SimpleFeatureSource featureSource; 75 private final MapContent content; 76 private boolean bIsChanged; 77 78 private final int layerOffset = 1; 79 80 private final ArrayList<GeomType> selectGeomType; 81 private final Color[] featureFills = { new Color(255, 0, 0), 82 new Color(0, 0, 255), // duplicate ways 83 new Color(204, 204, 0), // minor 5 84 new Color(255, 230, 128), // minor 2 85 new Color(255, 204, 0), // minor 1 86 new Color(255, 102, 102), // major 5 87 new Color(255, 148, 77), // major 2 88 new Color(255, 0, 0), // major 1 89 new Color(255, 255, 64), // selected 90 new Color(255, 0, 0), new Color(255, 0, 0) }; 91 92 /** 93 * dialog showing the bug info 94 */ 95 private final OsmInspectorDialog dialog; 96 97 /** 98 * supported actions 99 */ 100 101 // Container for bugs from Osmi 102 private List<OSMIFeatureTracker> arrFeatures; 103 private final LinkedHashMap<BugInfo, Long> osmiBugInfo; 104 105 public Geometry getOsmBugGeometry(int index) { 106 BugInfo[] array = new BugInfo[osmiBugInfo.keySet().size()]; 107 array = osmiBugInfo.keySet().toArray(array); 108 return array[index].getGeom(); 109 } 110 111 public Map<BugInfo, Long> getOsmiBugInfo() { 112 return osmiBugInfo; 113 } 114 115 public SimpleFeatureSource getFeatureSource() { 116 return featureSource; 117 } 118 119 public void setFeatureSource(SimpleFeatureSource featureSource) { 120 this.featureSource = featureSource; 121 } 122 123 public boolean isbIsChanged() { 124 return bIsChanged; 125 } 126 127 public void setbIsChanged(boolean bIsChanged) { 128 this.bIsChanged = bIsChanged; 129 } 130 131 public List<OSMIFeatureTracker> getArrFeatures() { 132 return arrFeatures; 133 } 134 135 public void setArrFeatures(List<OSMIFeatureTracker> arrFeatures) { 136 this.arrFeatures = arrFeatures; 137 } 138 139 public BugIndex getOsmiIndex() { 140 return osmiIndex; 141 } 142 143 // Pointer to prev and next osmi bugs 144 private final BugIndex osmiIndex; 145 146 /** 147 * 148 * The Bug attribute class: hold geom, id and description for that bug 149 * 150 * @author snikhil 151 * 152 */ 153 public static class BugInfo implements Comparable<BugInfo>{ 154 155 public Geometry getGeom() { 156 return geom; 157 } 158 159 public String getDesc() { 160 return desc; 161 } 162 163 public String getId() { 164 return id; 165 } 166 167 @Override 168 public int hashCode() { 169 String fid = attributes.get("FID"); 170 String hash = (fid == null || fid.isEmpty()) ? attributes.get("problem_id") : fid; 171 return hash.hashCode(); 172 } 173 174 @Override 175 public boolean equals(Object obj) { 176 String fid = attributes.get("FID"); 177 String hash = (fid == null || fid.isEmpty()) ? attributes.get("problem_id") : fid; 178 179 180 if (obj instanceof BugInfo) { 181 BugInfo b = (BugInfo) obj; 182 183 String bfid = b.attributes.get("FID"); 184 String bhash = (bfid == null || bfid.isEmpty()) ? b.attributes.get("problem_id") : bfid; 185 return hash.equals(bhash); 186 } 187 return false; 188 } 189 190 // private final long bugId; //incremental bugId 191 private final long bugId; 192 private final Geometry geom; 193 private final String desc; 194 private final String id; 195 private final Name name; 196 private final Map<String, String> attributes; 197 198 public BugInfo(SimpleFeature next, long idx) 199 throws IndexOutOfBoundsException, ParseException { 200 201 bugId = idx; 202 attributes = new HashMap<>(); 203 Collection<Property> properties = next.getProperties(); 204 for (Property p : properties) { 205 attributes.put(p.getName().toString(), p.getValue().toString()); 206 } 207 this.geom = (Geometry) next.getAttribute(0); 208 this.desc = (String) next.getAttribute("error_desc"); 209 this.id = next.getID(); 210 name = next.getName(); 211 } 212 213 @Override 214 public String toString() { 215 return "BugId_" + bugId + "\n"; 216 } 217 218 public String getContentString() { 219 StringBuilder sb = new StringBuilder(); 220 sb.append("Layer:").append(name.getLocalPart()).append("\n"); 221 for (Entry<String, String> next : attributes.entrySet()) { 222 sb.append(next.getKey()).append(":").append(next.getValue()) 223 .append("\n"); 224 } 225 return sb.toString(); 226 } 227 228 public long getBugId() { 229 return bugId; 230 } 231 232 @Override 233 public int compareTo(BugInfo o) { 234 String fid = attributes.get("FID"); 235 String hash = (fid == null || fid.isEmpty()) ? attributes.get("problem_id") : fid; 236 237 String ofid = o.attributes.get("FID"); 238 String ohash = (ofid == null || ofid.isEmpty()) ? o.attributes.get("problem_id") : ofid; 239 return hash.compareTo(ohash); 240 } 241 } 242 243 /** 244 * Helper class that stores the bug next and prev pointers and can navigate 245 * the entire bug list 246 * 247 * @author snikhil 248 * 249 */ 250 public static class BugIndex { 251 private int nextIndex; 252 private int previousIndex; 253 private final ArrayList<BugInfo> osmBugs; 254 255 public BugIndex(Map<BugInfo, Long> bugs) { 256 osmBugs = new ArrayList<>(bugs.keySet()); 257 nextIndex = 0; 258 previousIndex = -1; 259 } 260 261 public BugIndex(Map<BugInfo, Long> bugs, int n, int p) { 262 osmBugs = new ArrayList<>(bugs.keySet()); 263 nextIndex = n; 264 previousIndex = p; 265 } 266 267 public void next() { 268 previousIndex = nextIndex; 269 nextIndex = ++nextIndex % osmBugs.size(); 270 } 271 272 public void prev() { 273 nextIndex = previousIndex; 274 previousIndex = previousIndex - 1 < 0 ? osmBugs.size() - 1 275 : --previousIndex; 276 } 277 278 public BugInfo getItemPointedByNext() { 279 return osmBugs.get(nextIndex); 280 } 281 282 public BugInfo getItemPointedByPrev() { 283 return osmBugs.get(nextIndex); 284 } 285 286 public int indexOf(BugInfo b) { 287 return osmBugs.indexOf(b); 288 } 289 290 public BugInfo getNext() { 291 next(); 292 return osmBugs.get(nextIndex); 293 } 294 295 public BugInfo getPrev() { 296 prev(); 297 return osmBugs.get(nextIndex); 298 } 299 300 public List<BugInfo> getBugs() { 301 return osmBugs; 302 } 303 304 public void append(Map<BugInfo, Long> osmiBugInfo) { 305 for (BugInfo next : osmiBugInfo.keySet()) { 306 if (!osmBugs.contains(next)) { 307 this.osmBugs.add(next); 308 } 309 } 310 } 311 } 312 313 private enum GeomType { 314 POINT, LINE, POLYGON 315 } 316 317 private static final Color SELECTED_COLOUR = Color.ORANGE; 318 private static final float SELECTED_POINT_SIZE = 15.0f; 319 private static final float OPACITY = 1.0f; 320 private static final float LINE_WIDTH = 1.0f; 321 private static final float POINT_SIZE = 10.0f; 322 323 public OsmInspectorLayer(GeoFabrikWFSClient wfsClient, 324 ProgressMonitor monitor) throws NoSuchAuthorityCodeException, 325 FactoryException, IOException, IndexOutOfBoundsException, 326 ParseException { 327 super("OsmInspector"); 328 329 arrFeatures = new ArrayList<>(); 330 osmiBugInfo = new LinkedHashMap<>(); 331 selectGeomType = new ArrayList<>(); 332 333 // Step 3 - discovery; enhance to iterate over all types with bounds 334 335 String[] typeNames = wfsClient.getTypeNames(); 336 renderer = new StreamingRenderer(); 337 CRS.decode(ProjectionRegistry.getProjection().toCode()); 338 crsOSMI = CRS.decode("EPSG:4326"); 339 content = new MapContent(); 340 content.getViewport().setCoordinateReferenceSystem(crsOSMI); 341 342 selectGeomType.add(GeomType.POINT); 343 for (int idx = 1; idx < typeNames.length; ++idx) { 344 String typeName = typeNames[idx]; 345 Set<FeatureId> selectedFeatures = new HashSet<>(); 346 347 FeatureCollection<SimpleFeatureType, SimpleFeature> features = wfsClient 348 .getFeatures(typeName, monitor); 349 setGeometry(selectGeomType, typeName); 350 351 Logging.info("Osm Inspector Features size: " + features.size()); 352 Style style = createDefaultStyle(idx, selectedFeatures); 353 354 OSMIFeatureTracker tracker = new OSMIFeatureTracker(features); 355 arrFeatures.add(tracker); 356 FeatureIterator<SimpleFeature> it = tracker.getFeatures().features(); 357 358 while (it.hasNext()) { 359 BugInfo theInfo = new BugInfo(it.next(), osmiBugInfo.size()); 360 osmiBugInfo.put(theInfo, theInfo.bugId); 361 } 362 363 content.addLayer(new FeatureLayer(tracker.getFeatures(), style)); 364 } 365 366 osmiIndex = new BugIndex(osmiBugInfo); 367 content.setTitle("Osm Inspector Errors"); 368 renderer.setMapContent(content); 369 bIsChanged = true; 370 371 // finally initialize the dialog 372 dialog = new OsmInspectorDialog(this); 373 this.updateView(); 374 } 375 376 public void loadFeatures(GeoFabrikWFSClient wfsClient) 377 throws NoSuchAuthorityCodeException, FactoryException, IOException, 378 IndexOutOfBoundsException, NoSuchElementException, ParseException { 379 String[] typeNames = wfsClient.getTypeNames(); 380 381 content.layers().clear(); 382 selectGeomType.clear(); 383 selectGeomType.add(GeomType.POINT); 384 385 ProgressMonitor monitor = new ProgressMonitor(MainApplication.getMap().mapView, 386 "Loading features", "", 0, 100); 387 388 for (int idx = 1; idx < typeNames.length; ++idx) { 389 String typeName = typeNames[idx]; 390 Set<FeatureId> selectedFeatures = new HashSet<>(); 391 392 monitor.setProgress(100 / typeNames.length * idx); 393 FeatureCollection<SimpleFeatureType, SimpleFeature> features = wfsClient 394 .getFeatures(typeName, monitor); 395 setGeometry(selectGeomType, typeName); 396 397 Logging.info("Osm Inspector Features size: " + features.size()); 398 399 OSMIFeatureTracker tracker = arrFeatures.get(idx - layerOffset); 400 tracker.mergeFeatures(features); 401 402 FeatureIterator<SimpleFeature> it = tracker.getFeatures().features(); 403 404 while (it.hasNext()) { 405 BugInfo theInfo = new BugInfo(it.next(), osmiBugInfo.size()); 406 if (!osmiBugInfo.containsKey(theInfo)) { 407 osmiBugInfo.put(theInfo, theInfo.bugId); 408 } 409 } 410 411 Style style = createDefaultStyle(idx, selectedFeatures); 412 content.addLayer(new FeatureLayer(tracker.getFeatures(), style)); 413 } 414 415 osmiIndex.append(osmiBugInfo); 416 417 418 monitor.setProgress(100); 419 monitor.close(); 420 bIsChanged = true; 421 //dialog.updateDialog(this); 422 dialog.refreshModel(); 423 //dialog.updateNextPrevAction(this); 424 425 this.updateView(); 426 } 427 428 private Style createDefaultStyle(int idx, Set<FeatureId> IDs) { 429 Color fillColor = featureFills[idx]; 430 431 Rule selectedRule = createRule(SELECTED_COLOUR, SELECTED_COLOUR, true); 432 selectedRule.setFilter(ff.id(IDs)); 433 434 Rule rule = createRule(fillColor, fillColor, false); 435 rule.setElseFilter(true); 436 437 FeatureTypeStyle fts = sf.createFeatureTypeStyle(); 438 fts.rules().add(selectedRule); 439 fts.rules().add(rule); 440 441 Style style = sf.createStyle(); 442 style.featureTypeStyles().add(fts); 443 return style; 444 } 445 446 private Rule createRule(Color outlineColor, Color fillColor, 447 boolean bSelected) { 448 Symbolizer symbolizer = null; 449 Fill fill = null; 450 Stroke stroke = sf.createStroke(ff.literal(outlineColor), 451 ff.literal(LINE_WIDTH)); 452 453 switch (geometryType) { 454 case POLYGON: 455 fill = sf.createFill(ff.literal(fillColor), ff.literal(OPACITY)); 456 symbolizer = sf.createPolygonSymbolizer(stroke, fill, 457 geometryAttributeName); 458 break; 459 460 case LINE: 461 symbolizer = sf.createLineSymbolizer(stroke, geometryAttributeName); 462 break; 463 464 case POINT: 465 fill = sf.createFill(ff.literal(fillColor), ff.literal(OPACITY)); 466 467 Mark mark = sf.getTriangleMark(); 468 mark.setFill(fill); 469 mark.setStroke(stroke); 470 471 Graphic graphic = sf.createDefaultGraphic(); 472 graphic.graphicalSymbols().clear(); 473 graphic.graphicalSymbols().add(mark); 474 graphic.setSize(ff.literal(bSelected ? SELECTED_POINT_SIZE 475 : POINT_SIZE)); 476 477 symbolizer = sf.createPointSymbolizer(graphic, 478 geometryAttributeName); 479 } 480 481 Rule rule = sf.createRule(); 482 rule.symbolizers().add(symbolizer); 483 return rule; 484 } 485 486 private void setGeometry(ArrayList<GeomType> selectedTypes, String typename) { 487 Logging.info("Passed type is" + typename); 488 if (typename.compareTo("duplicate_ways") == 0) { 489 geometryType = GeomType.LINE; 490 } else 491 geometryType = GeomType.POINT; 492 493 selectedTypes.add(geometryType); 494 } 495 496 @Override 497 public Icon getIcon() { 498 return ImageProvider.get("layer/osmdata_small"); 499 } 500 501 @Override 502 public Object getInfoComponent() { 503 return getToolTipText(); 504 } 505 506 @Override 507 public Action[] getMenuEntries() { 508 return new Action[] {}; 509 } 510 511 @Override 512 public String getToolTipText() { 513 return org.openstreetmap.josm.tools.I18n.tr("OsmInspector"); 514 } 515 516 @Override 517 public boolean isMergable(Layer other) { 518 return false; 519 } 520 521 @Override 522 public void mergeFrom(Layer from) { 523 return; 524 } 525 526 @Override 527 public void paint(Graphics2D g, MapView mv, Bounds box) { 528 LatLon min = box.getMin(); 529 LatLon max = box.getMax(); 530 531 Envelope envelope2 = new Envelope(Math.min(min.lat(), max.lat()), 532 Math.max(min.lat(), max.lat()), Math.min(min.lon(), max.lon()), 533 Math.max(min.lon(), max.lon())); 534 535 ReferencedEnvelope mapArea = new ReferencedEnvelope(envelope2, crsOSMI); 536 537 renderer.setInteractive(false); 538 renderer.paint(g, mv.getBounds(), mapArea); 539 bIsChanged = false; 540 } 541 542 @Override 543 public void visitBoundingBox(BoundingXYVisitor v) { 544 } 545 546 public boolean isChanged() { 547 return bIsChanged; 548 } 549 550 public void updateView() { 551 this.dialog.revalidate(); 552 invalidate(); 553 } 554 555 public void selectFeatures(int x, int y) { 556 int pixelDelta = 2; 557 LatLon clickUL = MainApplication.getMap().mapView.getLatLon(x - pixelDelta, y 558 - pixelDelta); 559 LatLon clickLR = MainApplication.getMap().mapView.getLatLon(x + pixelDelta, y 560 + pixelDelta); 561 562 Envelope envelope = new Envelope( 563 Math.min(clickUL.lon(), clickLR.lon()), Math.max(clickUL.lon(), 564 clickLR.lon()), Math.min(clickUL.lat(), clickLR.lat()), 565 Math.max(clickUL.lat(), clickLR.lat())); 566 567 ReferencedEnvelope mapArea = new ReferencedEnvelope(envelope, crsOSMI); 568 569 Intersects filter = ff.intersects(ff.property("msGeometry"), 570 ff.literal(mapArea)); 571 // 572 // Select features in all layers 573 // 574 content.layers().clear(); 575 576 // Iterate through features and build a list that intersects the above 577 // envelope 578 for (int idx = 0; idx < arrFeatures.size(); ++idx) { 579 OSMIFeatureTracker tracker = arrFeatures.get(idx); 580 FeatureCollection<SimpleFeatureType, SimpleFeature> features = tracker 581 .getFeatures(); 582 583 SimpleFeatureSource tempfs = DataUtilities.source(features); 584 FeatureCollection<SimpleFeatureType, SimpleFeature> selectedFeatures; 585 586 try { 587 selectedFeatures = tempfs.getFeatures(filter); 598 588 Set<FeatureId> IDs = new HashSet<>(); 599 589 600 590 try (FeatureIterator<SimpleFeature> iter = selectedFeatures.features()) { 601 591 602 592 Logging.info("Selected features " + selectedFeatures.size()); 603 593 604 while (iter.hasNext()) { 605 SimpleFeature feature = iter.next(); 606 IDs.add(feature.getIdentifier()); 607 } 608 } 609 610 geometryType = selectGeomType.get(idx + layerOffset); 611 Style style = createDefaultStyle(idx + layerOffset, IDs); 612 content.addLayer(new FeatureLayer(features, style)); 613 } catch (IOException e) { 614 Logging.error(e); 615 } 616 } 617 618 bIsChanged = true; 619 } 620 621 public void selectFeatures(LatLon center) { 622 Point point = MainApplication.getMap().mapView.getPoint(center); 623 selectFeatures(point.x, point.y); 624 } 625 626 public void setOsmiIndex(int firstIndex) { 627 osmiIndex.nextIndex = firstIndex; 628 osmiIndex.previousIndex = firstIndex - 1 >= 0 ? firstIndex - 1 629 : osmiBugInfo.size() - 1; 630 } 631 594 while (iter.hasNext()) { 595 SimpleFeature feature = iter.next(); 596 IDs.add(feature.getIdentifier()); 597 } 598 } 599 600 geometryType = selectGeomType.get(idx + layerOffset); 601 Style style = createDefaultStyle(idx + layerOffset, IDs); 602 content.addLayer(new FeatureLayer(features, style)); 603 } catch (IOException e) { 604 Logging.error(e); 605 } 606 } 607 608 bIsChanged = true; 609 } 610 611 public void selectFeatures(LatLon center) { 612 Point point = MainApplication.getMap().mapView.getPoint(center); 613 selectFeatures(point.x, point.y); 614 } 615 616 public void setOsmiIndex(int firstIndex) { 617 osmiIndex.nextIndex = firstIndex; 618 osmiIndex.previousIndex = firstIndex - 1 >= 0 ? firstIndex - 1 619 : osmiBugInfo.size() - 1; 620 } 632 621 } -
applications/editors/josm/plugins/OsmInspectorPlugin/src/org/openstreetmap/josm/plugins/osminspector/OsmInspectorPlugin.java
r34538 r36176 26 26 MouseListener, PreferenceChangedListener, DownloadSelection{ 27 27 28 28 /** The JOSM user identity manager, it is used for obtaining the user name */ 29 29 private final UserIdentityManager userIdentityManager; 30 30 … … 35 35 private OsmInspectorLayer inspectorLayer; 36 36 37 38 39 40 41 42 43 37 public OsmInspectorPlugin(PluginInformation info) { 38 super(info); 39 userIdentityManager = UserIdentityManager.getInstance(); 40 initializePlugin(); 41 } 42 43 /** 44 44 * Initialize the <code>OsmInspectorPlugin</code> object. Creates the 45 45 * <code>OsmInspectorGUI</code> and initializes the following variables with … … 59 59 inspectorLayer = null; 60 60 } 61 62 63 64 61 @Override 62 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 63 MainApplication.getToolbar().register( new ImportOsmInspectorBugsAction( this ) ); 64 if (newFrame == null) { 65 65 /* if new MapFrame is null, remove listener */ 66 66 NavigatableComponent.removeZoomChangeListener(this); … … 81 81 } 82 82 } 83 83 } 84 84 85 @Override 86 public void zoomChanged() { 87 88 } 85 @Override 86 public void zoomChanged() { 89 87 90 @Override 91 // 92 // Delegate feature selection to layer 93 // 94 public void mouseClicked(MouseEvent e) { 95 if (inspectorLayer != null) { 96 inspectorLayer.selectFeatures(e.getX(), e.getY()); 97 } 98 } 88 } 99 89 100 @Override 101 public void mouseEntered(MouseEvent e) { 102 103 } 90 @Override 91 // 92 // Delegate feature selection to layer 93 // 94 public void mouseClicked(MouseEvent e) { 95 if (inspectorLayer != null) { 96 inspectorLayer.selectFeatures(e.getX(), e.getY()); 97 } 98 } 104 99 105 @Override 106 public void mouseExited(MouseEvent e) { 107 108 } 100 @Override 101 public void mouseEntered(MouseEvent e) { 109 102 110 @Override 111 public void mousePressed(MouseEvent e) { 112 113 } 103 } 114 104 115 @Override 116 public void mouseReleased(MouseEvent e) { 117 118 } 105 @Override 106 public void mouseExited(MouseEvent e) { 119 107 120 @Override 121 public void preferenceChanged(PreferenceChangeEvent e) { 122 123 } 108 } 124 109 125 public OsmInspectorLayer getLayer() 126 { 127 return inspectorLayer; 128 } 110 @Override 111 public void mousePressed(MouseEvent e) { 129 112 130 public void setLayer( OsmInspectorLayer theLayer ) 131 { 132 inspectorLayer = theLayer; 133 } 113 } 134 114 135 @Override 136 public void addGui(DownloadDialog gui) { 137 // TODO Auto-generated method stub 138 } 115 @Override 116 public void mouseReleased(MouseEvent e) { 139 117 140 @Override 141 public void setDownloadArea(Bounds bounds) { 142 // TODO Auto-generated method stub 143 } 118 } 119 120 @Override 121 public void preferenceChanged(PreferenceChangeEvent e) { 122 123 } 124 125 public OsmInspectorLayer getLayer() 126 { 127 return inspectorLayer; 128 } 129 130 public void setLayer( OsmInspectorLayer theLayer ) 131 { 132 inspectorLayer = theLayer; 133 } 134 135 @Override 136 public void addGui(DownloadDialog gui) { 137 // TODO Auto-generated method stub 138 } 139 140 @Override 141 public void setDownloadArea(Bounds bounds) { 142 // TODO Auto-generated method stub 143 } 144 144 } -
applications/editors/josm/plugins/OsmInspectorPlugin/src/org/openstreetmap/josm/plugins/osminspector/gui/OsmInspectorBugInfoDialog.java
r33793 r36176 4 4 5 5 import java.awt.event.KeyEvent; 6 import java.util. Arrays;6 import java.util.Collections; 7 7 8 8 import javax.swing.JTextPane; 9 9 10 10 import org.openstreetmap.josm.gui.MainApplication; 11 import org.openstreetmap.josm.gui.SideButton;12 11 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 13 12 import org.openstreetmap.josm.plugins.osminspector.OsmInspectorLayer; … … 17 16 public class OsmInspectorBugInfoDialog extends ToggleDialog { 18 17 19 18 private JTextPane bugTextArea; 20 19 21 /** 22 * Builds the content panel for this dialog 23 */ 24 protected void buildContentPanel() { 25 MainApplication.getMap().addToggleDialog(this, true); 26 27 bugTextArea = new JTextPane(); 28 createLayout(bugTextArea, true, Arrays.asList(new SideButton[] {})); 29 bugTextArea.setText("This is a demo"); 30 this.add(bugTextArea); 31 } 20 /** 21 * Builds the content panel for this dialog 22 */ 23 protected void buildContentPanel() { 24 MainApplication.getMap().addToggleDialog(this, true); 32 25 33 public OsmInspectorBugInfoDialog(OsmInspectorLayer layer) { 26 bugTextArea = new JTextPane(); 27 createLayout(bugTextArea, true, Collections.emptyList()); 28 bugTextArea.setText("This is a demo"); 29 this.add(bugTextArea); 30 } 34 31 35 super(tr("OsmBugInfo"), "select", 36 tr("Open a OSM Inspector selection list window."), Shortcut.registerShortcut("subwindow:select", 37 tr("Toggle: {0}", tr("Current Selected Bug Info")), 38 KeyEvent.VK_D, Shortcut.ALT_SHIFT), 150, // default 39 // height 40 true // default is "show dialog" 41 ); 42 buildContentPanel(); 43 } 32 public OsmInspectorBugInfoDialog(OsmInspectorLayer layer) { 44 33 45 public void updateDialog(OsmInspectorLayer l) { 46 } 47 48 public void setBugDescription(BugInfo i){ 49 bugTextArea.setText(i.getContentString()); 50 } 51 52 @Override 53 public void hideNotify() { 54 if (dialogsPanel != null) { 55 super.hideNotify(); 56 } 57 } 34 super(tr("OsmBugInfo"), "select", 35 tr("Open a OSM Inspector selection list window."), Shortcut.registerShortcut("subwindow:select", 36 tr("Toggle: {0}", tr("Current Selected Bug Info")), 37 KeyEvent.VK_D, Shortcut.ALT_SHIFT), 150, // default 38 // height 39 true // default is "show dialog" 40 ); 41 buildContentPanel(); 42 } 43 44 public void updateDialog(OsmInspectorLayer l) { 45 } 46 47 public void setBugDescription(BugInfo i){ 48 bugTextArea.setText(i.getContentString()); 49 } 50 51 @Override 52 public void hideNotify() { 53 if (dialogsPanel != null) { 54 super.hideNotify(); 55 } 56 } 58 57 } -
applications/editors/josm/plugins/OsmInspectorPlugin/src/org/openstreetmap/josm/plugins/osminspector/gui/OsmInspectorDialog.java
r35123 r36176 4 4 5 5 import java.awt.event.ActionEvent; 6 import java.awt.event.ActionListener;7 6 import java.awt.event.KeyEvent; 8 7 import java.util.Arrays; … … 14 13 import javax.swing.ListSelectionModel; 15 14 import javax.swing.ScrollPaneConstants; 16 import javax.swing.event.ListSelectionEvent; 17 import javax.swing.event.ListSelectionListener;18 15 16 import org.locationtech.jts.geom.Geometry; 17 import org.locationtech.jts.geom.Point; 19 18 import org.openstreetmap.josm.data.coor.LatLon; 20 19 import org.openstreetmap.josm.gui.MainApplication; … … 32 31 import org.openstreetmap.josm.tools.Shortcut; 33 32 34 import org.locationtech.jts.geom.Geometry;35 import org.locationtech.jts.geom.Point;36 37 33 public class OsmInspectorDialog extends ToggleDialog implements LayerChangeListener, ActiveLayerChangeListener { 38 34 39 private OsmInspectorLayer layer; 40 private JList<String> bugsList; 41 private OsmInspectorNextAction actNext; 42 private OsmInspectorPrevAction actPrev; 43 private DefaultListModel<String> model; 44 45 private OsmInspectorBugInfoDialog bugInfoDialog; 46 47 public void updateNextPrevAction(OsmInspectorLayer l) { 48 this.actNext.inspectlayer = l; 49 this.actPrev.inspectlayer = l; 50 } 51 52 /** 53 * Builds the content panel for this dialog 54 */ 55 protected void buildContentPanel() { 56 MainApplication.getMap().addToggleDialog(this, true); 57 58 model = new DefaultListModel<>(); 59 refreshModel(); 60 bugsList = new JList<>(model); 61 bugsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 62 bugsList.setLayoutOrientation(JList.VERTICAL_WRAP); 63 64 bugsList.setVisibleRowCount(-1); 65 JScrollPane scroll = new JScrollPane(bugsList, 66 ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, 67 ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); 68 69 bugsList.addListSelectionListener(new ListSelectionListener() { 70 71 @Override 72 public void valueChanged(ListSelectionEvent e) { 73 layer.setOsmiIndex(e.getFirstIndex()); 74 BugInfo next = layer.getOsmiIndex().getItemPointedByNext(); 75 layer.setOsmiIndex((e.getFirstIndex() + 1) % layer.getOsmiBugInfo().size()); 76 Geometry geom = next.getGeom(); 77 Point centroid = geom.getCentroid(); 78 LatLon center = new LatLon(centroid.getY(), centroid.getX()); 79 MainApplication.getMap().mapView.zoomTo(center); 80 layer.selectFeatures(center); 81 bugInfoDialog.setBugDescription(next); 82 } 83 }); 84 85 // refreshBugList(); 86 // the next action 87 final SideButton nextButton = new SideButton( 88 actNext = new OsmInspectorNextAction(layer)); 89 nextButton.createArrow(new ActionListener() { 90 @Override 91 public void actionPerformed(ActionEvent e) { 92 int index = bugsList.getSelectedIndex(); 93 Geometry geom = layer.getOsmBugGeometry(index); 94 Point centroid = geom.getCentroid(); 95 LatLon center = new LatLon(centroid.getY(), centroid.getX()); 96 MainApplication.getMap().mapView.zoomTo(center); 97 layer.selectFeatures(center); 98 } 99 }); 100 101 // the previous button 102 final SideButton prevButton = new SideButton( 103 actPrev = new OsmInspectorPrevAction(layer)); 104 prevButton.createArrow(new ActionListener() { 105 @Override 106 public void actionPerformed(ActionEvent e) { 107 } 108 }); 109 110 createLayout(scroll, true, 111 Arrays.asList(new SideButton[] { nextButton, prevButton })); 112 this.add(scroll); 113 114 Shortcut sprev = Shortcut.registerShortcut("osmi:prev", tr("Prev OSMI bug"), 115 KeyEvent.VK_J, Shortcut.CTRL_SHIFT); 116 MainApplication.registerActionShortcut(actPrev, sprev); 117 118 Shortcut snext = Shortcut.registerShortcut("osmi:next", tr("Next OSMI bug"), 119 KeyEvent.VK_K, Shortcut.CTRL_SHIFT); 120 MainApplication.registerActionShortcut(actNext, snext); 121 } 122 123 public void refreshModel() { 124 model.clear(); 125 for (Object b : layer.getOsmiBugInfo().keySet()) { 126 if (b instanceof BugInfo) { 127 model.addElement(b.toString()); 128 } 129 } 130 } 131 132 public OsmInspectorDialog(OsmInspectorLayer layer) { 133 134 super(tr("OSM Inspector Bugs"), "selectionlist", 135 tr("Open a OSM Inspector selection list window."), Shortcut.registerShortcut("subwindow:osminspector", 136 tr("Toggle: {0}", tr("OSM Inspector Bugs")), 137 KeyEvent.VK_W, Shortcut.ALT_SHIFT), 150, // default height 138 true // default is "show dialog" 139 ); 140 this.layer = layer; 141 buildContentPanel(); 142 bugInfoDialog = new OsmInspectorBugInfoDialog(layer); 143 bugInfoDialog.setTitle(tr("Selected Bug Info")); 144 } 145 146 public void updateDialog(OsmInspectorLayer l) { 147 this.layer = l; 148 bugInfoDialog.updateDialog(l); 149 refreshModel(); 150 refreshBugList(); 151 } 152 153 @Override 154 public void showNotify() { 155 super.showNotify(); 156 } 157 158 @Override 159 public void hideNotify() { 160 if (dialogsPanel != null) { 161 super.hideNotify(); 162 } 163 } 164 165 public class OsmInspectorNextAction extends AbstractAction { 166 167 private OsmInspectorLayer inspectlayer; 168 169 public OsmInspectorNextAction(Layer inspector) { 170 super("next"); 171 inspectlayer = (OsmInspectorLayer) inspector; 172 } 173 174 @Override 175 public void actionPerformed(ActionEvent e) { 176 inspectlayer.getOsmiIndex().next(); 177 BugInfo next = inspectlayer.getOsmiIndex().getItemPointedByNext(); 178 Geometry geom = next.getGeom(); 179 Point centroid = geom.getCentroid(); 180 LatLon center = new LatLon(centroid.getY(), centroid.getX()); 181 MainApplication.getMap().mapView.zoomTo(center); 182 inspectlayer.selectFeatures(center); 183 bugInfoDialog.setBugDescription(next); 184 updateSelection(next); 185 } 186 } 187 188 private void updateSelection(BugInfo prev) { 189 int idx = layer.getOsmiIndex().indexOf(prev); 190 if (idx >= 0) { 191 bugsList.setSelectedIndex(idx); 192 } 193 } 194 195 private class OsmInspectorPrevAction extends AbstractAction { 196 197 private OsmInspectorLayer inspectlayer; 198 199 public OsmInspectorPrevAction(Layer inspector) { 200 super("prev"); 201 inspectlayer = (OsmInspectorLayer) inspector; 202 } 203 204 @Override 205 public void actionPerformed(ActionEvent e) { 206 inspectlayer.getOsmiIndex().prev(); 207 BugInfo prev = inspectlayer.getOsmiIndex().getItemPointedByPrev(); 208 Geometry geom = prev.getGeom(); 209 Point centroid = geom.getCentroid(); 210 LatLon center = new LatLon(centroid.getY(), centroid.getX()); 211 MainApplication.getMap().mapView.zoomTo(center); 212 inspectlayer.selectFeatures(center); 213 bugInfoDialog.setBugDescription(prev); 214 updateSelection(prev); 215 } 216 } 217 218 @Override 219 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 220 Layer newLayer = MainApplication.getLayerManager().getActiveLayer(); 221 if (newLayer instanceof OsmInspectorLayer) { 222 this.layer = (OsmInspectorLayer) newLayer; 223 refreshModel(); 224 refreshBugList(); 225 } 226 } 227 228 private void refreshBugList() { 229 bugsList.clearSelection(); 230 bugsList = new JList<>(model); 231 } 232 233 @Override 234 public void layerAdded(LayerAddEvent e) { 235 if (layer != null) { 236 refreshModel(); 237 refreshBugList(); 238 } 239 } 240 241 @Override 242 public void layerRemoving(LayerRemoveEvent e) { 243 if (layer != null) { 244 bugsList.clearSelection(); 245 model.clear(); 246 } 247 } 35 private OsmInspectorLayer layer; 36 private JList<String> bugsList; 37 private OsmInspectorNextAction actNext; 38 private OsmInspectorPrevAction actPrev; 39 private DefaultListModel<String> model; 40 41 private final OsmInspectorBugInfoDialog bugInfoDialog; 42 43 public void updateNextPrevAction(OsmInspectorLayer l) { 44 this.actNext.inspectlayer = l; 45 this.actPrev.inspectlayer = l; 46 } 47 48 /** 49 * Builds the content panel for this dialog 50 */ 51 protected void buildContentPanel() { 52 MainApplication.getMap().addToggleDialog(this, true); 53 54 model = new DefaultListModel<>(); 55 refreshModel(); 56 bugsList = new JList<>(model); 57 bugsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 58 bugsList.setLayoutOrientation(JList.VERTICAL_WRAP); 59 60 bugsList.setVisibleRowCount(-1); 61 JScrollPane scroll = new JScrollPane(bugsList, 62 ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, 63 ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); 64 65 bugsList.addListSelectionListener(e -> { 66 layer.setOsmiIndex(e.getFirstIndex()); 67 BugInfo next = layer.getOsmiIndex().getItemPointedByNext(); 68 layer.setOsmiIndex((e.getFirstIndex() + 1) % layer.getOsmiBugInfo().size()); 69 Geometry geom = next.getGeom(); 70 Point centroid = geom.getCentroid(); 71 LatLon center = new LatLon(centroid.getY(), centroid.getX()); 72 MainApplication.getMap().mapView.zoomTo(center); 73 layer.selectFeatures(center); 74 bugInfoDialog.setBugDescription(next); 75 }); 76 77 // refreshBugList(); 78 // the next action 79 final SideButton nextButton = new SideButton( 80 actNext = new OsmInspectorNextAction(layer)); 81 nextButton.createArrow(e -> { 82 int index = bugsList.getSelectedIndex(); 83 Geometry geom = layer.getOsmBugGeometry(index); 84 Point centroid = geom.getCentroid(); 85 LatLon center = new LatLon(centroid.getY(), centroid.getX()); 86 MainApplication.getMap().mapView.zoomTo(center); 87 layer.selectFeatures(center); 88 }); 89 90 // the previous button 91 actPrev = new OsmInspectorPrevAction(layer); 92 final SideButton prevButton = new SideButton(actPrev); 93 prevButton.createArrow(e -> { }); 94 95 createLayout(scroll, true, 96 Arrays.asList(nextButton, prevButton)); 97 this.add(scroll); 98 99 Shortcut sprev = Shortcut.registerShortcut("osmi:prev", tr("Prev OSMI bug"), 100 KeyEvent.VK_J, Shortcut.CTRL_SHIFT); 101 MainApplication.registerActionShortcut(actPrev, sprev); 102 103 Shortcut snext = Shortcut.registerShortcut("osmi:next", tr("Next OSMI bug"), 104 KeyEvent.VK_K, Shortcut.CTRL_SHIFT); 105 MainApplication.registerActionShortcut(actNext, snext); 106 } 107 108 public void refreshModel() { 109 model.clear(); 110 for (Object b : layer.getOsmiBugInfo().keySet()) { 111 if (b instanceof BugInfo) { 112 model.addElement(b.toString()); 113 } 114 } 115 } 116 117 public OsmInspectorDialog(OsmInspectorLayer layer) { 118 119 super(tr("OSM Inspector Bugs"), "selectionlist", 120 tr("Open a OSM Inspector selection list window."), Shortcut.registerShortcut("subwindow:osminspector", 121 tr("Toggle: {0}", tr("OSM Inspector Bugs")), 122 KeyEvent.VK_W, Shortcut.ALT_SHIFT), 150, // default height 123 true // default is "show dialog" 124 ); 125 this.layer = layer; 126 buildContentPanel(); 127 bugInfoDialog = new OsmInspectorBugInfoDialog(layer); 128 bugInfoDialog.setTitle(tr("Selected Bug Info")); 129 } 130 131 public void updateDialog(OsmInspectorLayer l) { 132 this.layer = l; 133 bugInfoDialog.updateDialog(l); 134 refreshModel(); 135 refreshBugList(); 136 } 137 138 @Override 139 public void showNotify() { 140 super.showNotify(); 141 } 142 143 @Override 144 public void hideNotify() { 145 if (dialogsPanel != null) { 146 super.hideNotify(); 147 } 148 } 149 150 public class OsmInspectorNextAction extends AbstractAction { 151 152 private OsmInspectorLayer inspectlayer; 153 154 public OsmInspectorNextAction(Layer inspector) { 155 super("next"); 156 inspectlayer = (OsmInspectorLayer) inspector; 157 } 158 159 @Override 160 public void actionPerformed(ActionEvent e) { 161 inspectlayer.getOsmiIndex().next(); 162 BugInfo next = inspectlayer.getOsmiIndex().getItemPointedByNext(); 163 Geometry geom = next.getGeom(); 164 Point centroid = geom.getCentroid(); 165 LatLon center = new LatLon(centroid.getY(), centroid.getX()); 166 MainApplication.getMap().mapView.zoomTo(center); 167 inspectlayer.selectFeatures(center); 168 bugInfoDialog.setBugDescription(next); 169 updateSelection(next); 170 } 171 } 172 173 private void updateSelection(BugInfo prev) { 174 int idx = layer.getOsmiIndex().indexOf(prev); 175 if (idx >= 0) { 176 bugsList.setSelectedIndex(idx); 177 } 178 } 179 180 private class OsmInspectorPrevAction extends AbstractAction { 181 182 private OsmInspectorLayer inspectlayer; 183 184 public OsmInspectorPrevAction(Layer inspector) { 185 super("prev"); 186 inspectlayer = (OsmInspectorLayer) inspector; 187 } 188 189 @Override 190 public void actionPerformed(ActionEvent e) { 191 inspectlayer.getOsmiIndex().prev(); 192 BugInfo prev = inspectlayer.getOsmiIndex().getItemPointedByPrev(); 193 Geometry geom = prev.getGeom(); 194 Point centroid = geom.getCentroid(); 195 LatLon center = new LatLon(centroid.getY(), centroid.getX()); 196 MainApplication.getMap().mapView.zoomTo(center); 197 inspectlayer.selectFeatures(center); 198 bugInfoDialog.setBugDescription(prev); 199 updateSelection(prev); 200 } 201 } 202 203 @Override 204 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 205 Layer newLayer = MainApplication.getLayerManager().getActiveLayer(); 206 if (newLayer instanceof OsmInspectorLayer) { 207 this.layer = (OsmInspectorLayer) newLayer; 208 refreshModel(); 209 refreshBugList(); 210 } 211 } 212 213 private void refreshBugList() { 214 bugsList.clearSelection(); 215 bugsList = new JList<>(model); 216 } 217 218 @Override 219 public void layerAdded(LayerAddEvent e) { 220 if (layer != null) { 221 refreshModel(); 222 refreshBugList(); 223 } 224 } 225 226 @Override 227 public void layerRemoving(LayerRemoveEvent e) { 228 if (layer != null) { 229 bugsList.clearSelection(); 230 model.clear(); 231 } 232 } 248 233 249 234 @Override -
applications/editors/josm/plugins/apache-commons/ivy.xml
r36034 r36176 4 4 <info organisation="org.openstreetmap.josm.plugins" module="apache-commons"/> 5 5 <dependencies> 6 <dependency org="com.github.luben" name="zstd-jni" rev="1.5. 2-5" conf="default->default"/>6 <dependency org="com.github.luben" name="zstd-jni" rev="1.5.5-6" conf="default->default"/> 7 7 <dependency org="org.apache.commons" name="commons-collections4" rev="4.4" conf="default->default"/> 8 <dependency org="org.apache.commons" name="commons-compress" rev="1.2 2" conf="default->default"/>8 <dependency org="org.apache.commons" name="commons-compress" rev="1.24.0" conf="default->default"/> 9 9 <dependency org="org.apache.commons" name="commons-imaging" rev="1.0-alpha3" conf="default->default"/> 10 10 <!-- Apache Commons IO does not use the standard org name --> 11 <dependency org="commons-io" name="commons-io" rev="2.1 1.0" conf="default->default"/>11 <dependency org="commons-io" name="commons-io" rev="2.14.0" conf="default->default"/> 12 12 <!-- Apache Commons Logging also does not use the standard org name --> 13 13 <dependency org="commons-logging" name="commons-logging" rev="1.2" conf="default->default"/> 14 <dependency org="org.apache.commons" name="commons-lang3" rev="3.1 2.0" conf="default->default"/>14 <dependency org="org.apache.commons" name="commons-lang3" rev="3.13.0" conf="default->default"/> 15 15 <dependency org="org.apache.commons" name="commons-math3" rev="3.6.1" conf="default->default"/> 16 16 <dependency org="org.apache.commons" name="commons-text" rev="1.10.0" conf="default->default"/> -
applications/editors/josm/plugins/apache-http/build.xml
r35523 r36176 18 18 <import file="../build-common.xml"/> 19 19 20 <target name=" resolve" description="--> retrieve dependencies with Ivy">21 < ivy:retrieve/>20 <target name="pre-compile" depends="fetch_dependencies"> 21 <!-- include fetch_dependencies task --> 22 22 </target> 23 24 <target name="dist" depends="resolve,plugin_common.dist"/>25 26 23 </project> -
applications/editors/josm/plugins/apache-http/ivy.xml
r35889 r36176 4 4 <info organisation="org.openstreetmap.josm.plugins" module="apache-http"/> 5 5 <dependencies> 6 <!-- Leave these in until at least 2021-03-01 so plugins can migrate --> 7 <dependency org="org.apache.httpcomponents" name="httpcore" rev="4.4.15" conf="default->default"/> 8 <dependency org="org.apache.httpcomponents" name="httpclient" rev="4.5.13" conf="default->default"/> 9 <dependency org="org.apache.httpcomponents" name="httpmime" rev="4.5.13" conf="default->default"/> 10 <!-- These are in a different namespace, so conflicts shouldn't occur. --> 11 <dependency org="org.apache.httpcomponents.client5" name="httpclient5" rev="5.1.2" conf="default->default"/> 6 <dependency org="org.apache.httpcomponents.client5" name="httpclient5" rev="5.2.1" conf="default->default"/> 12 7 <!-- We may want to add fluent, cache, and windows extensions in the future --> 13 8 </dependencies> -
applications/editors/josm/plugins/build-common.xml
r36173 r36176 32 32 <property name="java.lang.version" value="8" /> 33 33 <property name="javadoc.executable" value="javadoc" /> 34 <property name="javadoc.link" value="https://docs.oracle.com/javase/8/docs/api" />35 34 <property name="manifest" value="MANIFEST"/> 36 35 <property name="manifest.unixoid" value="MANIFEST-unixoid"/> … … 62 61 <condition property="isJava17"><matches string="${ant.java.version}" pattern="1[7-9]|[2-9][0-9]" /></condition> 63 62 <condition property="isJava21"><matches string="${ant.java.version}" pattern="2[1-9]|[3-9][0-9]" /></condition> 63 64 <!-- set the javadoc location --> 65 <property name="javadoc.link" value="https://docs.oracle.com/javase/8/docs/api" unless:set="isJava11"/> 66 <property name="javadoc.link" value="https://docs.oracle.com/en/java/javase/11/docs/api/" if:set="isJava11" unless:set="isJava17"/> 67 <property name="javadoc.link" value="https://docs.oracle.com/en/java/javase/17/docs/api/" if:set="isJava17" unless:set="isJava21"/> 68 <property name="javadoc.link" value="https://docs.oracle.com/en/java/javase/21/docs/api/" if:set="isJava21"/> 69 64 70 <!-- Disable jacoco on Java 21+ (Jacoco does not yet support Java 21+) --> 65 71 <condition property="coverageByDefault"> -
applications/editors/josm/plugins/cadastre-fr/build.xml
r36122 r36176 16 16 <property name="plugin.stage" value="60"/> 17 17 <property name="plugin.requires" value="apache-commons;ejml;jts;geotools"/> 18 <property name="plugin.minimum.java.version" value="11"/> 18 19 19 20 <!-- ** include targets that all plugins have in common ** --> -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionSaveRasterAs.java
r34668 r36176 21 21 import org.geotools.gce.geotiff.GeoTiffWriteParams; 22 22 import org.geotools.gce.geotiff.GeoTiffWriter; 23 import org.geotools.geometry. Envelope2D;23 import org.geotools.geometry.jts.ReferencedEnvelope; 24 24 import org.geotools.referencing.CRS; 25 import org. opengis.parameter.GeneralParameterValue;26 import org. opengis.parameter.ParameterValueGroup;25 import org.geotools.api.parameter.GeneralParameterValue; 26 import org.geotools.api.parameter.ParameterValueGroup; 27 27 import org.openstreetmap.josm.actions.JosmAction; 28 28 import org.openstreetmap.josm.gui.MainApplication; … … 37 37 private static final String NAME = marktr("Save image as..."); 38 38 39 private WMSLayer wmsLayer;39 private final WMSLayer wmsLayer; 40 40 41 41 static class FiltrePng extends FileFilter { … … 106 106 double x = wmsLayer.getImage(0).min.east(); 107 107 double y = wmsLayer.getImage(0).min.north(); 108 Envelope2D bbox = new Envelope2D(CRS.decode("EPSG:27561"),109 x,y,110 wmsLayer.getImage(0).max.east()-x, wmsLayer.getImage(0).max.north()-y);108 ReferencedEnvelope bbox = ReferencedEnvelope.rect(x, y, 109 wmsLayer.getImage(0).max.east() - x, wmsLayer.getImage(0).max.north() - y, 110 CRS.decode("EPSG:27561")); 111 111 GridCoverageFactory factory = new GridCoverageFactory(); 112 112 GridCoverage2D coverage = factory.create("tiff", bi, bbox); -
applications/editors/josm/plugins/comfort0/build.xml
r35976 r36176 18 18 <target name="pre-compile" depends="javacc"/> 19 19 <target name="javacc" depends="init,init-ivy" unless="javacc.notRequired"> 20 <ivy:settings file="${josm.ivysettings}" /> 20 21 <ivy:cachepath file="${core.tools.ivy}" pathid="javacc.classpath" conf="javacc"/> 21 22 <mkdir dir="${parser.dir}/parsergen"/> -
applications/editors/josm/plugins/ejml/build.xml
r35883 r36176 12 12 <property name="plugin.canloadatruntime" value="true"/> 13 13 <property name="plugin.stage" value="15"/> 14 <property name="plugin.minimum.java.version" value="11"/> 14 15 15 16 <!-- ** include targets that all plugins have in common ** --> -
applications/editors/josm/plugins/ejml/ivy.xml
r35885 r36176 5 5 <dependencies> 6 6 <!-- We included everything in 0.34, including experimental --> 7 <dependency org="org.ejml" name="ejml-all" rev="0.4 1"/>8 <dependency org="org.ejml" name="ejml-experimental" rev="0.4 1"/>7 <dependency org="org.ejml" name="ejml-all" rev="0.43.1"/> 8 <dependency org="org.ejml" name="ejml-experimental" rev="0.43.1"/> 9 9 </dependencies> 10 10 </ivy-module> -
applications/editors/josm/plugins/flatlaf/ivy.xml
r36128 r36176 2 2 <info organisation="org.openstreetmap.josm.plugins" module="flatlaf"/> 3 3 <dependencies> 4 <dependency conf="default->default" org="com.formdev" name="flatlaf" rev="3.2 "/>4 <dependency conf="default->default" org="com.formdev" name="flatlaf" rev="3.2.2"/> 5 5 </dependencies> 6 6 </ivy-module> -
applications/editors/josm/plugins/geotools/build.xml
r36028 r36176 13 13 <property name="plugin.requires" value="apache-commons;ejml;jackson;jaxb;jts"/> 14 14 <property name="plugin.stage" value="20"/> 15 <property name="plugin.minimum.java.version" value="11"/> 15 16 16 17 <!-- ** include targets that all plugins have in common ** --> -
applications/editors/josm/plugins/geotools/ivy.xml
r36024 r36176 11 11 <dependency org="org.geotools" name="gt-main" rev="${gt.version}" conf="default->default"/> 12 12 <dependency org="org.geotools" name="gt-metadata" rev="${gt.version}" conf="default->default"/> 13 <dependency org="org.geotools" name="gt- opengis" rev="${gt.version}" conf="default->default"/>13 <dependency org="org.geotools" name="gt-api" rev="${gt.version}" conf="default->default"/> 14 14 <dependency org="org.geotools" name="gt-referencing" rev="${gt.version}" conf="default->default"/> 15 15 <dependency org="org.geotools" name="gt-shapefile" rev="${gt.version}" conf="default->default"/> -
applications/editors/josm/plugins/geotools/ivy_settings.xml
r36068 r36176 2 2 <ivysettings> 3 3 <!-- When geotools is updated, run `ant merge-geotools-services` --> 4 <property name="gt.version" value="28.2"/> 4 <property name="gt.version" value="30.0"/> 5 <include file="${josm.ivysettings}" optional="true" /> <!-- optional for IDEs --> 5 6 <settings defaultResolver="ordered-resolvers"/> 6 7 <resolvers> -
applications/editors/josm/plugins/geotools/src/org/openstreetmap/josm/plugins/geotools/GeoToolsPlugin.java
r36015 r36176 4 4 import java.io.IOException; 5 5 import java.io.InputStream; 6 import java.util.Collection; 6 7 import java.util.Iterator; 7 8 import java.util.ServiceLoader; … … 15 16 import org.geotools.image.ImageWorker; 16 17 import org.geotools.referencing.CRS; 17 import org. opengis.referencing.FactoryException;18 import org. opengis.referencing.NoSuchAuthorityCodeException;18 import org.geotools.api.referencing.FactoryException; 19 import org.geotools.api.referencing.NoSuchAuthorityCodeException; 19 20 import org.openstreetmap.josm.plugins.Plugin; 20 21 import org.openstreetmap.josm.plugins.PluginInformation; … … 102 103 103 104 private static void checkEPSG() { 105 final Collection<String> codes = CRS.getSupportedCodes("EPSG"); 106 if (codes.isEmpty() || !(codes.contains("4326") || codes.contains("EPSG:4326"))) { 104 107 try { 105 CRS.decode("EPSG:4326"); 106 } catch (NoSuchAuthorityCodeException e) { 107 Logging.error("geotools: error in EPSG database initialization. NoSuchAuthorityCodeException: "+e.getMessage()); 108 } catch (FactoryException e) { 109 Logging.error("geotools: error in EPSG database initialization. FactoryException: "+e.getMessage()); 108 CRS.decode("EPSG:4326"); 109 } catch (NoSuchAuthorityCodeException e) { 110 Logging.error("geotools: error in EPSG database initialization. NoSuchAuthorityCodeException: " + e.getMessage()); 111 } catch (FactoryException e) { 112 Logging.error("geotools: error in EPSG database initialization. FactoryException: " + e.getMessage()); 113 } 110 114 } 111 115 } -
applications/editors/josm/plugins/jackson/ivy.xml
r36034 r36176 2 2 <!-- License: GPL. For details, see LICENSE file. --> 3 3 <ivy-module version="2.0"> 4 <info organisation="org.openstreetmap.josm.plugins" module=" geotools"/>4 <info organisation="org.openstreetmap.josm.plugins" module="jackson"/> 5 5 <dependencies> 6 <dependency org="com.fasterxml.jackson.core" name="jackson-core" rev="2.1 4.0" conf="default->default"/>6 <dependency org="com.fasterxml.jackson.core" name="jackson-core" rev="2.15.3" conf="default->default"/> 7 7 </dependencies> 8 8 </ivy-module> -
applications/editors/josm/plugins/jna/ivy.xml
r36005 r36176 5 5 </configurations> 6 6 <dependencies> 7 <dependency org="net.java.dev.jna" name="jna" rev="5.1 2.1"/>8 <dependency org="net.java.dev.jna" name="jna-platform" rev="5.1 2.1"/>7 <dependency org="net.java.dev.jna" name="jna" rev="5.13.0"/> 8 <dependency org="net.java.dev.jna" name="jna-platform" rev="5.13.0"/> 9 9 </dependencies> 10 10 </ivy-module> -
applications/editors/josm/plugins/log4j/ivy.xml
r36034 r36176 4 4 <info organisation="org.openstreetmap.josm.plugins" module="log4j"/> 5 5 <dependencies> 6 <dependency org="org.apache.logging.log4j" name="log4j-api" rev="2. 19.0" conf="default->default"/>7 <dependency org="org.apache.logging.log4j" name="log4j-1.2-api" rev="2. 19.0" conf="default->default"/>8 <dependency org="org.apache.logging.log4j" name="log4j-core" rev="2. 19.0" conf="default->default"/>6 <dependency org="org.apache.logging.log4j" name="log4j-api" rev="2.21.0" conf="default->default"/> 7 <dependency org="org.apache.logging.log4j" name="log4j-1.2-api" rev="2.21.0" conf="default->default"/> 8 <dependency org="org.apache.logging.log4j" name="log4j-core" rev="2.21.0" conf="default->default"/> 9 9 </dependencies> 10 10 </ivy-module> -
applications/editors/josm/plugins/lwjgl/ivy_settings.xml
r36034 r36176 2 2 <ivysettings> 3 3 <property name="joml.version" value="1.10.5"/> 4 <property name="lwjgl.version" value="3.3. 1"/>4 <property name="lwjgl.version" value="3.3.3"/> 5 5 <property name="lwjgl3-awt.version" value="0.1.8"/> 6 <include file="${josm.ivysettings}" optional="true"/> <!-- optional for IDEs --> 6 7 <settings defaultResolver="chained-resolver"/> 7 8 <resolvers> -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/at/AustrianGmlHandler.java
r36173 r36176 3 3 4 4 import org.geotools.referencing.CRS; 5 import org. opengis.referencing.FactoryException;6 import org. opengis.referencing.NoSuchAuthorityCodeException;7 import org. opengis.referencing.crs.CoordinateReferenceSystem;5 import org.geotools.api.referencing.FactoryException; 6 import org.geotools.api.referencing.NoSuchAuthorityCodeException; 7 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 8 8 import org.openstreetmap.josm.plugins.opendata.core.io.geographic.DefaultGmlHandler; 9 9 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/fr/FrenchShpHandler.java
r36072 r36176 5 5 import org.geotools.referencing.operation.projection.LambertConformal2SP; 6 6 import org.geotools.referencing.operation.projection.MapProjection.AbstractProvider; 7 import org. opengis.referencing.FactoryException;8 import org. opengis.referencing.crs.CoordinateReferenceSystem;9 import org. opengis.referencing.crs.ProjectedCRS;10 import org. opengis.referencing.datum.GeodeticDatum;11 import org. opengis.referencing.operation.MathTransform;7 import org.geotools.api.referencing.FactoryException; 8 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 9 import org.geotools.api.referencing.crs.ProjectedCRS; 10 import org.geotools.api.referencing.datum.GeodeticDatum; 11 import org.geotools.api.referencing.operation.MathTransform; 12 12 import org.openstreetmap.josm.plugins.opendata.core.io.geographic.DefaultShpHandler; 13 13 import org.openstreetmap.josm.plugins.opendata.core.io.geographic.GeotoolsHandler; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/DefaultGeographicHandler.java
r36173 r36176 3 3 4 4 import org.geotools.referencing.CRS; 5 import org. opengis.referencing.FactoryException;6 import org. opengis.referencing.NoSuchAuthorityCodeException;7 import org. opengis.referencing.crs.CoordinateReferenceSystem;5 import org.geotools.api.referencing.FactoryException; 6 import org.geotools.api.referencing.NoSuchAuthorityCodeException; 7 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 8 8 9 9 public abstract class DefaultGeographicHandler implements GeographicHandler { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/DefaultGmlHandler.java
r36072 r36176 3 3 4 4 import org.geotools.referencing.CRS; 5 import org. opengis.referencing.FactoryException;6 import org. opengis.referencing.crs.CoordinateReferenceSystem;7 import org. opengis.referencing.operation.MathTransform;5 import org.geotools.api.referencing.FactoryException; 6 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 7 import org.geotools.api.referencing.operation.MathTransform; 8 8 9 9 public class DefaultGmlHandler extends DefaultGeographicHandler implements GmlHandler { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/DefaultMifHandler.java
r36072 r36176 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.geographic; 3 3 4 import org. opengis.referencing.FactoryException;5 import org. opengis.referencing.crs.CoordinateReferenceSystem;6 import org. opengis.referencing.operation.MathTransform;4 import org.geotools.api.referencing.FactoryException; 5 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 6 import org.geotools.api.referencing.operation.MathTransform; 7 7 import org.openstreetmap.josm.data.projection.Projection; 8 8 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeographicHandler.java
r36072 r36176 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.geographic; 3 3 4 import org. opengis.referencing.FactoryException;5 import org. opengis.referencing.NoSuchAuthorityCodeException;6 import org. opengis.referencing.crs.CoordinateReferenceSystem;7 import org. opengis.referencing.operation.MathTransform;4 import org.geotools.api.referencing.FactoryException; 5 import org.geotools.api.referencing.NoSuchAuthorityCodeException; 6 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 7 import org.geotools.api.referencing.operation.MathTransform; 8 8 9 9 public interface GeographicHandler { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeographicReader.java
r36173 r36176 31 31 import org.locationtech.jts.geom.LineString; 32 32 import org.locationtech.jts.geom.Point; 33 import org. opengis.geometry.MismatchedDimensionException;34 import org. opengis.referencing.FactoryException;35 import org. opengis.referencing.IdentifiedObject;36 import org. opengis.referencing.crs.CoordinateReferenceSystem;37 import org. opengis.referencing.crs.ProjectedCRS;38 import org. opengis.referencing.cs.CoordinateSystem;39 import org. opengis.referencing.datum.Datum;40 import org. opengis.referencing.operation.MathTransform;41 import org. opengis.referencing.operation.OperationNotFoundException;42 import org. opengis.referencing.operation.TransformException;33 import org.geotools.api.geometry.MismatchedDimensionException; 34 import org.geotools.api.referencing.FactoryException; 35 import org.geotools.api.referencing.IdentifiedObject; 36 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 37 import org.geotools.api.referencing.crs.ProjectedCRS; 38 import org.geotools.api.referencing.cs.CoordinateSystem; 39 import org.geotools.api.referencing.datum.Datum; 40 import org.geotools.api.referencing.operation.MathTransform; 41 import org.geotools.api.referencing.operation.OperationNotFoundException; 42 import org.geotools.api.referencing.operation.TransformException; 43 43 import org.openstreetmap.josm.data.coor.ILatLon; 44 44 import org.openstreetmap.josm.data.coor.LatLon; … … 348 348 * @param parent The parent component, used for showing dialogs 349 349 * @param findSimiliarCrs {@code true} if we don't need to find the exact CRS 350 * @throws FactoryException See {@link CRS#findMathTransform}, {@link org. opengis.referencing.AuthorityFactory#getAuthorityCodes}350 * @throws FactoryException See {@link CRS#findMathTransform}, {@link org.geotools.api.referencing.AuthorityFactory#getAuthorityCodes} 351 351 * @throws UserCancelException If the user cancelled in one of the message dialogs 352 352 * @throws GeoMathTransformException If no transform could be found -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeotoolsConverter.java
r36173 r36176 18 18 import javax.swing.JOptionPane; 19 19 20 import org.geotools. data.DataStore;21 import org.geotools. data.FeatureSource;20 import org.geotools.api.data.DataStore; 21 import org.geotools.api.data.FeatureSource; 22 22 import org.geotools.feature.FeatureCollection; 23 23 import org.geotools.feature.FeatureIterator; … … 28 28 import org.locationtech.jts.geom.Polygon; 29 29 import org.locationtech.jts.io.ParseException; 30 import org. opengis.feature.Feature;31 import org. opengis.feature.GeometryAttribute;32 import org. opengis.feature.Property;33 import org. opengis.feature.type.GeometryDescriptor;34 import org. opengis.feature.type.Name;35 import org. opengis.geometry.MismatchedDimensionException;36 import org. opengis.referencing.FactoryException;37 import org. opengis.referencing.operation.TransformException;30 import org.geotools.api.feature.Feature; 31 import org.geotools.api.feature.GeometryAttribute; 32 import org.geotools.api.feature.Property; 33 import org.geotools.api.feature.type.GeometryDescriptor; 34 import org.geotools.api.feature.type.Name; 35 import org.geotools.api.geometry.MismatchedDimensionException; 36 import org.geotools.api.referencing.FactoryException; 37 import org.geotools.api.referencing.operation.TransformException; 38 38 import org.openstreetmap.josm.data.osm.DataSet; 39 39 import org.openstreetmap.josm.data.osm.OsmPrimitive; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeotoolsHandler.java
r36173 r36176 14 14 import org.geotools.referencing.operation.projection.LambertConformal2SP; 15 15 import org.geotools.referencing.operation.projection.MapProjection.AbstractProvider; 16 import org. opengis.parameter.ParameterDescriptor;17 import org. opengis.parameter.ParameterValueGroup;18 import org. opengis.referencing.FactoryException;19 import org. opengis.referencing.crs.CoordinateReferenceSystem;20 import org. opengis.referencing.datum.GeodeticDatum;21 import org. opengis.referencing.operation.MathTransform;16 import org.geotools.api.parameter.ParameterDescriptor; 17 import org.geotools.api.parameter.ParameterValueGroup; 18 import org.geotools.api.referencing.FactoryException; 19 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 20 import org.geotools.api.referencing.datum.GeodeticDatum; 21 import org.geotools.api.referencing.operation.MathTransform; 22 22 import org.openstreetmap.josm.data.projection.AbstractProjection; 23 23 import org.openstreetmap.josm.data.projection.Ellipsoid; … … 40 40 * A mapping of GeoTools ellipsoid to JOSM ellipsoids. Don't use outside the {@link GeotoolsHandler} class. 41 41 */ 42 List<Pair<org. opengis.referencing.datum.Ellipsoid, Ellipsoid>>42 List<Pair<org.geotools.api.referencing.datum.Ellipsoid, Ellipsoid>> 43 43 ellipsoids = Collections.unmodifiableList(Arrays.asList( 44 44 new Pair<>(DefaultEllipsoid.GRS80, Ellipsoid.GRS80), … … 63 63 AbstractProjection ap = (AbstractProjection) p; 64 64 if (ap.getProj() instanceof LambertConformalConic) { 65 for (Pair<org. opengis.referencing.datum.Ellipsoid, Ellipsoid> pair : ellipsoids) {65 for (Pair<org.geotools.api.referencing.datum.Ellipsoid, Ellipsoid> pair : ellipsoids) { 66 66 if (pair.a.equals(geo.getEllipsoid()) && pair.b.equals(ap.getEllipsoid())) { 67 67 boolean ok = true; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GmlReader.java
r36173 r36176 16 16 import org.locationtech.jts.geom.GeometryFactory; 17 17 import org.locationtech.jts.geom.Point; 18 import org. opengis.geometry.MismatchedDimensionException;19 import org. opengis.referencing.FactoryException;20 import org. opengis.referencing.crs.CoordinateReferenceSystem;21 import org. opengis.referencing.operation.MathTransform;22 import org. opengis.referencing.operation.TransformException;18 import org.geotools.api.geometry.MismatchedDimensionException; 19 import org.geotools.api.referencing.FactoryException; 20 import org.geotools.api.referencing.crs.CoordinateReferenceSystem; 21 import org.geotools.api.referencing.operation.MathTransform; 22 import org.geotools.api.referencing.operation.TransformException; 23 23 import org.openstreetmap.josm.data.osm.DataSet; 24 24 import org.openstreetmap.josm.data.osm.Node; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpReader.java
r36173 r36176 21 21 import java.util.Set; 22 22 23 import org.geotools. data.DataStore;23 import org.geotools.api.data.DataStore; 24 24 import org.geotools.data.shapefile.ShapefileDataStoreFactory; 25 25 import org.locationtech.jts.geom.Point; 26 import org. opengis.geometry.MismatchedDimensionException;27 import org. opengis.referencing.FactoryException;28 import org. opengis.referencing.operation.TransformException;26 import org.geotools.api.geometry.MismatchedDimensionException; 27 import org.geotools.api.referencing.FactoryException; 28 import org.geotools.api.referencing.operation.TransformException; 29 29 import org.openstreetmap.josm.data.osm.DataSet; 30 30 import org.openstreetmap.josm.data.osm.Node; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/geopackage/GeoPackageReader.java
r36071 r36176 10 10 import java.util.Map; 11 11 12 import org.geotools. data.DataStore;13 import org.geotools. data.DataStoreFinder;12 import org.geotools.api.data.DataStore; 13 import org.geotools.api.data.DataStoreFinder; 14 14 import org.geotools.geopkg.GeoPkgDataStoreFactory; 15 import org. opengis.referencing.FactoryException;16 import org. opengis.referencing.operation.TransformException;15 import org.geotools.api.referencing.FactoryException; 16 import org.geotools.api.referencing.operation.TransformException; 17 17 import org.openstreetmap.josm.data.osm.DataSet; 18 18 import org.openstreetmap.josm.gui.progress.ProgressMonitor; -
applications/editors/josm/plugins/pbf/ivy.xml
r36034 r36176 2 2 <info organisation="org.openstreetmap.josm.plugins" module="pbf"/> 3 3 <dependencies> 4 <dependency conf="default->default" org="com.google.protobuf" name="protobuf-java" rev="3.2 0.3"/>4 <dependency conf="default->default" org="com.google.protobuf" name="protobuf-java" rev="3.24.4"/> 5 5 <dependency conf="default->default" org="org.openstreetmap.pbf" name="osmpbf" rev="1.5.0"/> 6 6 </dependencies>
Note:
See TracChangeset
for help on using the changeset viewer.