Opened 2 years ago
Last modified 9 months ago
#22352 reopened defect
GeoJSON: when multiple nodes have the same coordinates, they are merged
Reported by: | tguen | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core geojson | Version: | |
Keywords: | template_report | Cc: | tguen@… |
Description
What steps will reproduce the problem?
- Import a .geojson file with multiple tagged nodes at the same location.
What is the expected result?
Each feature in the geojson file should be imported as a separate object
What happens instead?
Points with identical coordinates are imported as one object with merged tags
Please provide any additional information below. Attach a screenshot if possible.
Relative:URL: ^/trunk Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b Last:Changed Date: 2022-05-29 21:53:52 +0200 (Sun, 29 May 2022) Revision:18463 Build-Date:2022-05-30 01:30:57 URL:https://josm.openstreetmap.de/svn/trunk Identification: JOSM/1.5 (18463 en) Linux Arch Linux Memory Usage: 280 MB / 3936 MB (82 MB allocated, but free) Java version: 18.0.2+0, N/A, OpenJDK 64-Bit Server VM Look and Feel: javax.swing.plaf.metal.MetalLookAndFeel Screen: :0.0 2560×1440 (scaling 1.00×1.00) Maximum Screen Size: 2560×1440 Best cursor sizes: 16×16→16×16, 32×32→32×32 Environment variable LANG: en_US.UTF-8 System property file.encoding: UTF-8 System property sun.jnu.encoding: ANSI_X3.4-1968 Locale info: en_US Numbers with default locale: 1234567890 -> 1234567890 Desktop environment: KDE VM arguments: [--add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED, -Djosm.restart=true, -Dawt.useSystemAAFontSettings=on] Dataset consistency test: No problems found Plugins: + apache-commons (36003) + ejml (35924) + geotools (36015) + jackson (36006) + jaxb (35952) + jts (36004) + opendata (35910) + utilsplugin2 (35970) Last errors/warnings: - 00012.993 W: No valid coordinates have been found.
Attachments (1)
Change History (6)
by , 2 years ago
Attachment: | test_addr_stack.geojson added |
---|
comment:1 by , 2 years ago
Priority: | major → normal |
---|
This is a fairly easy "fix". The question is what other behavior is going to break.
-
src/org/openstreetmap/josm/io/GeoJSONReader.java
diff --git a/src/org/openstreetmap/josm/io/GeoJSONReader.java b/src/org/openstreetmap/josm/io/GeoJSONReader.java
a b 323 323 } 324 324 325 325 private Node createNode(final LatLon latlon) { 326 final List<Node> existingNodes = getDataSet().searchNodes(new BBox(latlon, latlon)); 327 if (!existingNodes.isEmpty()) { 326 final Optional<Node> existingEmptyNode = getDataSet().searchNodes(new BBox(latlon, latlon)).stream() 327 .filter(n -> !n.hasKeys()).findFirst(); 328 if (existingEmptyNode.isPresent()) { 328 329 // reuse existing node, avoid multiple nodes on top of each other 329 return existing Nodes.get(0);330 return existingEmptyNode.get(); 330 331 } 331 332 final Node node = new Node(latlon); 332 333 getDataSet().addPrimitive(node);
comment:2 by , 2 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Closed as duplicate of #21044.
comment:3 by , 2 years ago
comment:4 by , 2 years ago
Resolution: | duplicate |
---|---|
Status: | closed → reopened |
Fair enough.
I'd have to write tests for corner cases anyway. Like I said in comment:1, "[the] question is what other behavior is going to break."
comment:5 by , 9 months ago
I write .osm files to avoid the current merging behaviour, but I'd much prefer to be able to load geojsons.
example geojson file