[sosi2osm] 06/30: Add simple support for connection points

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 6b009c7365569b65bd6fbc48b7cacbdadbb9a927
Author: Knut Karevoll <gnonthgol at gmail.com>
Date:   Mon Oct 7 22:05:13 2013 +0200

    Add simple support for connection points
---
 sosi2osm.cpp | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/sosi2osm.cpp b/sosi2osm.cpp
index 1982ed9..3fe33ce 100644
--- a/sosi2osm.cpp
+++ b/sosi2osm.cpp
@@ -63,7 +63,38 @@ void getCoords(long int* size, double** lat, double** lon) {
 }
 
 long nodeId = -1;
-long createNode(double lat, double lon) {
+long createNode(double lat, double lon, short kp) {
+	if (kp == 0) {
+    	printf("<node id=\"%ld\" lat=\"%.7f\" lon=\"%.7f\" visible=\"true\"/>\n", nodeId, lat, lon);
+	    return nodeId--;
+    }
+    
+    static int sizeM = 0;
+    static int lenM = 0;
+    static double* latM = NULL;
+    static double* lonM = NULL;
+    static short* kpM = NULL;
+    static long* idM = NULL;
+    
+    for (int i = 0; i < lenM; i++) {
+    	if (lat == latM[i] && lon == lonM[i] && kp == kpM[i]) {
+    		return idM[i];
+    	}
+    }
+    
+    if (lenM >= sizeM) {
+    	sizeM = max(1024, sizeM*2);
+    	latM = (double*)realloc(latM, sizeof(double) * sizeM);
+    	lonM = (double*)realloc(lonM, sizeof(double) * sizeM);
+    	kpM = (short*)realloc(kpM, sizeof(short) * sizeM);
+    	idM = (long*)realloc(idM, sizeof(long) * sizeM);
+    }
+    
+    latM[lenM] = lat;
+    lonM[lenM] = lon;
+    kpM[lenM] = kp;
+    idM[lenM] = nodeId;
+    lenM++;
     printf("<node id=\"%ld\" lat=\"%.7f\" lon=\"%.7f\" visible=\"true\"/>\n", nodeId, lat, lon);
     return nodeId--;
 }
@@ -115,7 +146,7 @@ void outputWay() {
     long* nd = (long*)malloc(sizeof(long) * size);
     
     for (int i = 0; i < size; i++) {
-        nd[i] = createNode(lat[i], lon[i]);
+        nd[i] = createNode(lat[i], lon[i], LC_GetKp(i+1));
     }
     
     printf("<way id=\"%ld\" visible=\"true\">", -getSOSIId());

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