[sosi2osm] 08/30: Do not loose information when parsing lines from the sosi file

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 00ee8b6193202530ed278d7422814ad0e1a35594
Author: Knut Karevoll <gnonthgol at gmail.com>
Date:   Tue Oct 8 22:03:05 2013 +0200

    Do not loose information when parsing lines from the sosi file
---
 sosi.cpp     | 12 ++++++------
 sosi2osm.cpp |  4 ++--
 tag.cpp      |  6 ++++--
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/sosi.cpp b/sosi.cpp
index 5d44018..a94f1c7 100644
--- a/sosi.cpp
+++ b/sosi.cpp
@@ -60,13 +60,13 @@ short getSOSIType() {
 }
 
 long getSOSIId() {
-	return LC_GetSn();
+    return LC_GetSn();
 }
 
 const char* getCoordinateSystem() {
-	unsigned short mask = LC_TR_ALLT;
+    unsigned short mask = LC_TR_ALLT;
     LC_TRANSPAR trans;
-	if (LC_GetTransEx(&mask,&trans) == UT_FALSE) {
+    if (LC_GetTransEx(&mask,&trans) == UT_FALSE) {
         fprintf(stderr, "TRANSPAR section not found - No reference system information available.");
         return "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ";
     }
@@ -117,12 +117,12 @@ long getSOSICoordsSize() {
 }
 
 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)
+    char* tmp = r;
+    while (tmp[0] == '.') tmp++;
+    if (strncmp(tmp, "REF", 3) == 0)
         return NULL;
     
     return r;
diff --git a/sosi2osm.cpp b/sosi2osm.cpp
index 3914d57..6b6c0e1 100644
--- a/sosi2osm.cpp
+++ b/sosi2osm.cpp
@@ -13,8 +13,8 @@ void handleHead() {
     long lines = getSOSILinesLength();
     for (int i = 0; i < lines; i++) {
         char* line = getSOSILine(i);
-        if (line != NULL && strncmp(line, "TEGNSETT ", 9) == 0) {
-            setEncoding(line+9);
+        if (line != NULL && strncmp(line, "..TEGNSETT ", 11) == 0) {
+            setEncoding(line+11);
         }
     }
 }
diff --git a/tag.cpp b/tag.cpp
index 81e51b6..08c6383 100644
--- a/tag.cpp
+++ b/tag.cpp
@@ -5,7 +5,7 @@
 
 iconv_t charDescriptor;
 void setEncoding(char* encoding) {
-	charDescriptor = iconv_open("UTF-8", encoding);
+    charDescriptor = iconv_open("UTF-8", encoding);
 }
 
 char* toUTF8(char* in, char* outBuf, size_t outlen) {
@@ -25,9 +25,11 @@ char* toUTF8(char* in, char* outBuf, size_t outlen) {
 
 void outputTags() {
     long lines = getSOSILinesLength();
-    for (int i = 0; i < lines; i++) {
+    for (int i = 1; i < lines; i++) {
         char* key = getSOSILine(i);
         if (key != NULL) {
+            while (key[0] == '.') key++;
+            
             char* value = strchr(key, ' ');
             if (value != NULL) {
                 value[0] = '\0';

-- 
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