Skip to content

Commit cdbffed

Browse files
committed
first shot on a france métropolitaine renderer
1 parent a901887 commit cdbffed

4 files changed

Lines changed: 49 additions & 12 deletions

File tree

pom.xml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@
2727
<port>8080</port>
2828
</httpConnector>
2929
</configuration>
30+
</plugin>
31+
<plugin>
32+
<groupId>org.codehaus.mojo</groupId>
33+
<artifactId>exec-maven-plugin</artifactId>
34+
<version>1.6.0</version>
35+
<executions>
36+
<execution>
37+
<goals>
38+
<goal>exec</goal>
39+
</goals>
40+
</execution>
41+
</executions>
42+
<configuration>
43+
<includeProjectDependencies>true</includeProjectDependencies>
44+
<mainClass>fr.beneth.mapnik.EntryPoint</mainClass>
45+
<classpathScope>compile</classpathScope>
46+
</configuration>
3047
</plugin>
3148
</plugins>
3249
</build>
@@ -36,8 +53,7 @@
3653
<artifactId>mapnik</artifactId>
3754
<version>3.0.9</version>
3855
<scope>system</scope>
39-
<systemPath>/usr/share/java/mapnik-jni.jar
40-
</systemPath>
56+
<systemPath>/usr/share/java/mapnik-jni.jar</systemPath>
4157
</dependency>
4258
<dependency>
4359
<groupId>org.springframework</groupId>

src/main/java/fr/beneth/mapnik/EntryPoint.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,31 @@
1818
public class EntryPoint {
1919

2020
public static void main(String[] args) throws ClassNotFoundException, URISyntaxException, IOException {
21-
// Some java black magic to load the interned jar
22-
URL mapnikJniJar = EntryPoint.class.getResource("/lib/mapnik-jni.jar");
23-
URLClassLoader child = new URLClassLoader(new URL[] { mapnikJniJar }, EntryPoint.class.getClassLoader());
24-
Class.forName("mapnik.Mapnik", true, child);
2521

2622
Mapnik.initialize();
27-
28-
Box2d bounds = new Box2d(5.91478, 45.56237, 5.92904, 45.56921);
23+
// France métropolitaine
24+
// -9.86 41.15
25+
// 10.38 51.56
26+
Box2d bounds = new Box2d(-9.86, 41.15, 10.38, 51.56);
2927
MapDefinition m = new MapDefinition();
3028

31-
URL myMapFile = EntryPoint.class.getResource("/data/simplemap.xml");
29+
URL myMapFile = EntryPoint.class.getResource("/data/france.xml");
3230
// This should be done by the initialize() call, but ...
3331
FreetypeEngine.registerFonts(Mapnik.getInstalledFontsDir(), true);
3432

3533
m.loadMap(new File(myMapFile.toURI()).getAbsolutePath(), false);
3634
m.setSrs(Projection.LATLNG_PARAMS);
37-
m.resize(512, 512);
35+
m.resize(4096, 4096);
3836
m.zoomToBox(bounds);
3937

40-
Image image = new Image(512, 512);
38+
Image image = new Image(4096, 4096);
4139
Renderer.renderAgg(m, image);
4240

4341
byte[] contents = image.saveToMemory("png");
4442
image.dispose();
4543
m.dispose();
4644

47-
FileOutputStream fos = new FileOutputStream("chambery.png");
45+
FileOutputStream fos = new FileOutputStream("france.png");
4846
fos.write(contents);
4947
fos.flush();
5048
fos.close();

src/main/resources/data/france.geojson

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/main/resources/data/france.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Map background-color="#000" srs="+proj=longlat +datum=WGS84 +no_defs">
3+
<Style name="white">
4+
<Rule>
5+
<PolygonSymbolizer fill-opacity="1" fill="#fff"/>
6+
</Rule>
7+
</Style>
8+
<Style name="green">
9+
<Rule>
10+
<PolygonSymbolizer fill-opacity="0.8" fill="#0f0"/>
11+
</Rule>
12+
</Style>
13+
<Layer name="france.geojson" status="on" srs="+proj=longlat +datum=WGS84 +no_defs">
14+
<StyleName>white</StyleName>
15+
<Datasource>
16+
<Parameter name="type">ogr</Parameter>
17+
<Parameter name="file">france.geojson</Parameter>
18+
<Parameter name="layer">OGRGeoJSON</Parameter>
19+
</Datasource>
20+
</Layer>
21+
22+
</Map>

0 commit comments

Comments
 (0)