Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Unable to parse GeoJSON when type is set after coordinates

Open
#156 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
50/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
java
Domain
backend

Research direction

Reproduce the two GeoJSONReader.read calls with the LineString type placed before and after coordinates. Start at GeoJSONReader.readShapeFromCoordinates(GeoJSONReader.java:304), then trace readShape and read to determine why the property order causes a null value. Done means both inputs parse without a NullPointerException and equivalent shapes are returned.

Written by the indexing model from the issue text.

Description

When executing following code:

GeoJSONReader geojsonReader = new GeoJSONReader(new SpatialContext(new SpatialContextFactory()), 
				new SpatialContextFactory());
System.out.println("Type first:" + geojsonReader.read("{\"type\":\"LineString\", \"coordinates\":[[2.287563,48.862743],[2.287862,48.862958],[2.288109,48.863045]]}"));
System.out.println("Type second:" + geojsonReader.read("{\"coordinates\":[[2.287563,48.862743],[2.287862,48.862958],[2.288109,48.863045]],\"type\":\"LineString\"}"));

the following exception is thrown at line 3:

java.lang.NullPointerException
	at org.locationtech.spatial4j.io.GeoJSONReader.readShapeFromCoordinates(GeoJSONReader.java:304)
	at org.locationtech.spatial4j.io.GeoJSONReader.readShape(GeoJSONReader.java:248)
	at org.locationtech.spatial4j.io.GeoJSONReader.read(GeoJSONReader.java:48)
	at org.locationtech.spatial4j.io.GeoJSONReader.read(GeoJSONReader.java:54)
Dominant language
Java
Stars
962
Forks
174
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from locationtech/spatial4j

All issues in locationtech/spatial4j

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.