Modify

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?

  1. 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)

test_addr_stack.geojson (1.0 KB ) - added by tguen 2 years ago.
example geojson file

Download all attachments as: .zip

Change History (6)

by tguen, 2 years ago

Attachment: test_addr_stack.geojson added

example geojson file

comment:1 by taylor.smock, 2 years ago

Priority: majornormal

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  
    323323    }
    324324
    325325    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()) {
    328329            // reuse existing node, avoid multiple nodes on top of each other
    329             return existingNodes.get(0);
     330            return existingEmptyNode.get();
    330331        }
    331332        final Node node = new Node(latlon);
    332333        getDataSet().addPrimitive(node);

comment:2 by taylor.smock, 2 years ago

Resolution: duplicate
Status: newclosed

Closed as duplicate of #21044.

comment:3 by skyper, 2 years ago

Probably, better reopen this ticket as #21044 already has a milestone and should remain as "fixed".

I guess for nodes without parent it will work but how about nodes with parents, especially first or last node of a way? Do we run into the problems of #19041, again?

comment:4 by taylor.smock, 2 years ago

Resolution: duplicate
Status: closedreopened

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 CjMalone, 9 months ago

I write .osm files to avoid the current merging behaviour, but I'd much prefer to be able to load geojsons.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as reopened The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user. Next status will be 'new'.
Next status will be 'needinfo'. The owner will be changed from team to tguen.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.