]> mj.ucw.cz Git - leo.git/commitdiff
Support for reading of shape files (partial)
authorMartin Mares <mj@ucw.cz>
Tue, 7 Oct 2014 12:56:43 +0000 (14:56 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 7 Oct 2014 12:56:43 +0000 (14:56 +0200)
map.c
map.cf
map.h
shp.c

diff --git a/map.c b/map.c
index 8f318e23e9427bafa5a65a7baf5417a2d1ed68ad..8f502006324660fe42329f89a797452652c040d3 100644 (file)
--- a/map.c
+++ b/map.c
@@ -15,6 +15,7 @@
 
 #include "leo.h"
 #include "osm.h"
+#include "shp.h"
 #include "map.h"
 #include "css.h"
 #include "sym.h"
@@ -44,6 +45,7 @@ static const char * const map_formats[] = {
   "invalid",
   "osmxml",
   "fixed",
+  "shape",
 };
 
 static struct cf_section map_source_cf = {
@@ -236,6 +238,13 @@ static void map_load_source(struct data_source *ds)
       msg(L_INFO, "Adding fixed objects");
       fixed_add();
       break;
+    case DATA_SOURCE_SHAPE:
+      msg(L_INFO, "Parsing %s as shape file", ds->file);
+      if (!ds->file)
+       die("Shape data sources must have a file name");
+      shp_parse(ds->file);
+      need_proj = 1;
+      break;
     default:
       die("Invalid data source format");
     }
diff --git a/map.cf b/map.cf
index 92a2435409b2412594140eb2a2845ac1f7599ccf..809f77f50f31db1b66f3a410b38e73bbc5b423d9 100644 (file)
--- a/map.cf
+++ b/map.cf
@@ -7,6 +7,7 @@ Map {
                # File format:
                #       osmxml          OpenStreetMap XML
                #       fixed           Fixed objects (no File used, see FixedObjects section below)
+               #       shape           ESRI shape file (partial support only)
                Format osmxml
 
                # MapCSS stylesheet to apply (multiple style-sheets are allowed)
diff --git a/map.h b/map.h
index 2fa4f89bbbc6d1b2c94c309eae09d716f556d328..9dd80a795bea79538b51b186ef7f7ad3278959bf 100644 (file)
--- a/map.h
+++ b/map.h
@@ -23,6 +23,7 @@ enum data_source_type {
   DATA_SOURCE_INVALID,
   DATA_SOURCE_OSMXML,
   DATA_SOURCE_FIXED,
+  DATA_SOURCE_SHAPE,
 };
 
 struct data_source {
diff --git a/shp.c b/shp.c
index 383525e5fb46a2c49e11239b3b83ecc0be45f187..0e0ff54a0cdb6ada76e236a541ab6b2f2e077520 100644 (file)
--- a/shp.c
+++ b/shp.c
@@ -23,8 +23,7 @@
 #include "map.h"
 #include "shp.h"
 
-// FIXME: Hack
-static osm_id_t shp_id_counter = 1000000000000;
+static osm_id_t shp_id_counter;
 
 static double shp_get_double(byte *p)
 {
@@ -69,6 +68,7 @@ void shp_parse(const char *name)
 {
   msg(L_INFO, "Loading shape file %s", name);
   struct fastbuf *fb = bopen_file(name, O_RDONLY, NULL);
+  shp_id_counter = 1;
 
   byte *buf;
   GARY_INIT(buf, 100);