[sosi2osm] 03/30: Add support for tags
Ruben Undheim
rubund-guest at moszumanska.debian.org
Sat Oct 4 13:07:54 UTC 2014
This is an automated email from the git hooks/post-receive script.
rubund-guest pushed a commit to branch upstream
in repository sosi2osm.
commit 248da51ff6f9717291dbb515aa1124fba1926a40
Author: Knut Karevoll <gnonthgol at gmail.com>
Date: Mon Oct 7 12:23:31 2013 +0200
Add support for tags
---
.gitignore | 1 +
sosi.cpp | 24 +++++++++++++++++++++++-
sosi2osm.cpp | 20 +++++++++++++++++++-
sosi2osm.h | 4 +++-
4 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/.gitignore b/.gitignore
index b3ddb88..d2e180c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*.o
sosi2osm
+*~
diff --git a/sosi.cpp b/sosi.cpp
index e991c96..2d327c3 100644
--- a/sosi.cpp
+++ b/sosi.cpp
@@ -1,3 +1,5 @@
+#include <string.h>
+
#include "sosi2osm.h"
LC_BASEADM* base = NULL;
@@ -102,7 +104,7 @@ const char* getCoordinateSystem() {
}
}
-void getSOSICoord(int i, double* x, double* y) {
+void getSOSICoord(long i, double* x, double* y) {
LC_GetTK(i+1, x, y);
}
@@ -114,3 +116,23 @@ long getSOSICoordsSize() {
return coordinates;
}
+char* getSOSILine(long i) {
+ if (i == 0) return NULL;
+ char* r = LC_GetGi(i+1);
+ if (r[0] == ':' || r[0] == '(' || r[0] == '!')
+ return NULL;
+ while (r[0] == '.') r++;
+ if (strncmp(r, "REF", 3) == 0)
+ return NULL;
+
+ return r;
+}
+
+long getSOSILinesLength() {
+ short lines;
+ long coordinates;
+ unsigned short info;
+ LC_GetGrPara(&lines, &coordinates, &info);
+ return lines;
+}
+
diff --git a/sosi2osm.cpp b/sosi2osm.cpp
index a929fe3..ab34a21 100644
--- a/sosi2osm.cpp
+++ b/sosi2osm.cpp
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <string.h>
#include <proj_api.h>
#include "sosi2osm.h"
@@ -42,7 +43,23 @@ long createNode(double lat, double lon) {
}
void outputTags() {
-
+ long lines = getSOSILinesLength();
+ for (int i = 0; i < lines; i++) {
+ char* key = getSOSILine(i);
+ if (key != NULL) {
+ char* value = strchr(key, ' ');
+ if (value != NULL) {
+ value[0] = '\0';
+ value++;
+ while (value[0] == '"') value++;
+ char* last = value + strlen(value);
+ while (last[-1] == '"') last--;
+ *last = '\0';
+
+ printf("<tag k=\"%s\" v=\"%s\"/>\n", key, value);
+ }
+ }
+ }
}
void outputNode() {
@@ -111,6 +128,7 @@ int main(int argc, char** args) {
break;
case L_FLATE:
outputRelation();
+ break;
case L_PUNKT:
case L_SYMBOL:
case L_TEKST:
diff --git a/sosi2osm.h b/sosi2osm.h
index c9ec8cd..5bd5017 100644
--- a/sosi2osm.h
+++ b/sosi2osm.h
@@ -8,6 +8,8 @@ int nextSOSIObject();
short getSOSIType();
long getSOSIId();
const char* getCoordinateSystem();
-void getSOSICoord(int i, double* x, double* y);
+void getSOSICoord(long i, double* x, double* y);
long getSOSICoordsSize();
+char* getSOSILine(long i);
+long getSOSILinesLength();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/sosi2osm.git
More information about the Pkg-grass-devel
mailing list