From 9984564bf78208f9b16e9736a7fd5c768f7dc41d Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 7 Oct 2014 14:56:43 +0200 Subject: [PATCH] Support for reading of shape files (partial) --- map.c | 9 +++++++++ map.cf | 1 + map.h | 1 + shp.c | 4 ++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/map.c b/map.c index 8f318e2..8f50200 100644 --- 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 92a2435..809f77f 100644 --- 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 2fa4f89..9dd80a7 100644 --- 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 383525e..0e0ff54 100644 --- 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); -- 2.39.2