-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature concatenate geojson with object properties (#205)
* Update ShardFileOverlapsPolygon to match shard resources of other types * Handle null (empty) subatlas after filtering single resource in load() * Use org.openstreetmap.atlas.utilities.collections.Iterables * Add prototype changes for ConcatenateGeoJsonCommand * Concatenate geojson files while preserving data types of properties * Sort input files to make output order deterministic * Apply spotless java
- Loading branch information
Showing
8 changed files
with
203 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/test/java/org/openstreetmap/atlas/geography/geojson/ConcatenateGeoJsonCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package org.openstreetmap.atlas.geography.geojson; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.junit.Assert; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
/** | ||
* Test cases for ConcatenateGeoJsonFiles. | ||
* | ||
* @author rmegraw | ||
*/ | ||
public class ConcatenateGeoJsonCommandTest | ||
{ | ||
@Rule | ||
public TemporaryFolder tempFolder = new TemporaryFolder(); | ||
|
||
@Test | ||
public void testConcatenateGeoJsonFiles() throws IOException | ||
{ | ||
final String inputPath = new File(this.getClass().getResource("test1.geojson").getPath()) | ||
.getParent(); | ||
final String outputPath = this.tempFolder.newFile().getAbsolutePath(); | ||
|
||
new ConcatenateGeoJsonCommand().runWithoutQuitting("-path=" + inputPath, "-mode=FILE", | ||
"-output=" + outputPath); | ||
|
||
final File outputFile = new File(outputPath); | ||
Assert.assertTrue(outputFile.exists()); | ||
|
||
Assert.assertTrue(FileUtils | ||
.readFileToString(new File(this.getClass() | ||
.getResource("concatenated_geojson_files_expected").getPath()), | ||
Charset.defaultCharset()) | ||
.equals(FileUtils.readFileToString(outputFile, Charset.defaultCharset()))); | ||
|
||
} | ||
|
||
@Test | ||
public void testConcatenateGeoJsonLines() throws IOException | ||
{ | ||
final String inputPath = new File(this.getClass().getResource("test1.geojson").getPath()) | ||
.getParent(); | ||
final String outputPath = this.tempFolder.newFile().getAbsolutePath(); | ||
|
||
new ConcatenateGeoJsonCommand().runWithoutQuitting("-path=" + inputPath, "-mode=LINE", | ||
"-output=" + outputPath, "-filePrefix=" + "test"); | ||
|
||
final File outputFile = new File(outputPath); | ||
Assert.assertTrue(outputFile.exists()); | ||
|
||
Assert.assertTrue(FileUtils | ||
.readFileToString(new File(this.getClass() | ||
.getResource("concatenated_geojson_files_expected").getPath()), | ||
Charset.defaultCharset()) | ||
.equals(FileUtils.readFileToString(outputFile, Charset.defaultCharset()))); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...t/resources/org/openstreetmap/atlas/geography/geojson/concatenated_geojson_files_expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-71.0,-37.0],[-72.0,-38.0]]},"properties":{"prop1":"foo","prop2":1.99,"prop3":[1,2,3]}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-72.0,-38.0],[-73.0,-39.0]]},"properties":{"prop1":"bar","prop2":2.99,"prop3":[2,3,4]}}]} |
1 change: 1 addition & 0 deletions
1
src/test/resources/org/openstreetmap/atlas/geography/geojson/test1.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-71,-37],[-72,-38]]},"properties":{"prop1":"foo","prop2":1.99,"prop3":[1,2,3]}}]} |
1 change: 1 addition & 0 deletions
1
src/test/resources/org/openstreetmap/atlas/geography/geojson/test2.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-72,-38],[-73,-39]]},"properties":{"prop1":"bar","prop2":2.99,"prop3":[2,3,4]}}]} |