Skip to content

Commit 1960b0f

Browse files
vvikaskarussell
authored andcommitted
OSM Shapefile importer graphhopper#616 and graphhopper#874
1 parent 698f25b commit 1960b0f

File tree

16 files changed

+1024
-9
lines changed

16 files changed

+1024
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ local.properties
4141
.DS_Store
4242
/core/nbproject/
4343
/reader-overlay-data/nbproject/
44+
!malta-latest.osm.pbf

CONTRIBUTORS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ Most of the contributors are mentioned at Github as [Members](https://github.com
3737
* mprins, improvements for travis CI and regarding JDK9 #806
3838
* NopMap, massive improvements regarding OSM, parsing and encoding, route relations
3939
* ocampana, initial implementation for instructions
40+
* PGWelch, shapefile reader #874
4041
* ratrun, route relations, GPX information, bike handling etc
4142
* rajanski, script to do routing via PostGIS
4243
* rodneyodonnell, improved dead end removal and fords
4344
* rodo, more descriptions
4445
* seeebiii, motorcycle improvements
4546
* Svantulden, improved documentation and nearest API
4647
* thehereward, code cleanups like #620
47-
* vvikas, ideas for many to many improvements
48+
* vvikas, ideas for many to many improvements and #616
4849

4950
## Translations
5051

pom.xml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,7 @@
6969
<system>GitHub</system>
7070
<url>https://github.com/graphhopper/graphhopper/issues</url>
7171
</issueManagement>
72-
<modules>
73-
<module>tools-lgpl</module>
74-
<module>core</module>
75-
<module>reader-osm</module>
76-
<module>reader-overlay-data</module>
77-
<module>tools</module>
78-
<module>web</module>
79-
</modules>
72+
8073
<prerequisites>
8174
<maven>3.2</maven>
8275
</prerequisites>
@@ -279,6 +272,16 @@
279272
<activeByDefault>true</activeByDefault>
280273
</activation>
281274
<properties />
275+
<!-- update below module list too -->
276+
<modules>
277+
<module>tools-lgpl</module>
278+
<module>core</module>
279+
<module>reader-osm</module>
280+
<module>reader-shp</module>
281+
<module>reader-overlay-data</module>
282+
<module>tools</module>
283+
<module>web</module>
284+
</modules>
282285
<build>
283286
<plugins>
284287
<plugin>
@@ -298,6 +301,18 @@
298301
<jdk>9</jdk>
299302
</activation>
300303
<properties />
304+
<modules>
305+
<module>tools-lgpl</module>
306+
<module>core</module>
307+
<module>reader-osm</module>
308+
<!-- See https://github.com/graphhopper/graphhopper/pull/874#issuecomment-261231518
309+
maybe there is a parameter solution for this instead
310+
<module>reader-shp</module>
311+
-->
312+
<module>reader-overlay-data</module>
313+
<module>tools</module>
314+
<module>web</module>
315+
</modules>
301316
<build>
302317
<plugins>
303318
<plugin>

reader-shp/pom.xml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.graphhopper</groupId>
7+
<artifactId>graphhopper-reader-shp</artifactId>
8+
<version>0.9-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
<name>GraphHopper Reader for Shapefile Data</name>
11+
12+
<properties>
13+
<geotools.version>15.2</geotools.version>
14+
</properties>
15+
16+
<parent>
17+
<groupId>com.graphhopper</groupId>
18+
<artifactId>graphhopper-parent</artifactId>
19+
<version>0.9-SNAPSHOT</version>
20+
</parent>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>com.graphhopper</groupId>
25+
<artifactId>graphhopper-core</artifactId>
26+
<version>${project.parent.version}</version>
27+
</dependency>
28+
29+
<dependency>
30+
<groupId>org.geotools</groupId>
31+
<artifactId>gt-shapefile</artifactId>
32+
<version>${geotools.version}</version>
33+
</dependency>
34+
35+
<dependency>
36+
<groupId>org.slf4j</groupId>
37+
<artifactId>slf4j-api</artifactId>
38+
<version>${slf4j.version}</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.slf4j</groupId>
42+
<artifactId>slf4j-log4j12</artifactId>
43+
<version>${slf4j.version}</version>
44+
<scope>runtime</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>log4j</groupId>
48+
<artifactId>log4j</artifactId>
49+
<version>${log4j.version}</version>
50+
<scope>runtime</scope>
51+
</dependency>
52+
53+
<dependency>
54+
<!-- Include the pbf reader for test purposes -->
55+
<groupId>com.graphhopper</groupId>
56+
<artifactId>graphhopper-reader-osm</artifactId>
57+
<version>${project.parent.version}</version>
58+
<scope>test</scope>
59+
</dependency>
60+
</dependencies>
61+
<build>
62+
<plugins>
63+
<plugin>
64+
<groupId>org.apache.maven.plugins</groupId>
65+
<artifactId>maven-compiler-plugin</artifactId>
66+
<version>3.5.1</version>
67+
<configuration>
68+
<source>1.8</source>
69+
<target>1.8</target>
70+
</configuration>
71+
</plugin>
72+
</plugins>
73+
</build>
74+
<repositories>
75+
<repository>
76+
<id>osgeo</id>
77+
<name>Open Source Geospatial Foundation Repository</name>
78+
<url>http://download.osgeo.org/webdav/geotools/</url>
79+
</repository>
80+
</repositories>
81+
82+
</project>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed to GraphHopper GmbH under one or more contributor
3+
* license agreements. See the NOTICE file distributed with this work for
4+
* additional information regarding copyright ownership.
5+
*
6+
* GraphHopper GmbH licenses this file to you under the Apache License,
7+
* Version 2.0 (the "License"); you may not use this file except in
8+
* compliance with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package com.graphhopper.reader.shp;
19+
20+
import java.util.HashSet;
21+
22+
import com.graphhopper.GraphHopper;
23+
import com.graphhopper.reader.DataReader;
24+
import com.graphhopper.reader.shp.OSMShapeFileReader.EdgeAddedListener;
25+
import com.graphhopper.storage.GraphHopperStorage;
26+
27+
/**
28+
*
29+
* @author Phil
30+
*
31+
*/
32+
public class GraphhopperSHP extends GraphHopper {
33+
private final HashSet<EdgeAddedListener> edgeAddedListeners = new HashSet<>();
34+
35+
@Override
36+
protected DataReader createReader(GraphHopperStorage ghStorage) {
37+
OSMShapeFileReader reader = new OSMShapeFileReader(ghStorage);
38+
for (EdgeAddedListener l : edgeAddedListeners) {
39+
reader.addListener(l);
40+
}
41+
return initDataReader(reader);
42+
}
43+
44+
public void addListener(EdgeAddedListener l) {
45+
edgeAddedListeners.add(l);
46+
}
47+
48+
}

0 commit comments

Comments
 (0)