[Wsplgen-commits] r137 - trunk/src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Dec 11 10:06:36 CET 2008


Author: mrchip
Date: 2008-12-11 10:06:32 +0100 (Thu, 11 Dec 2008)
New Revision: 137

Modified:
   trunk/src/file.cpp
   trunk/src/test_xy.cpp
   trunk/src/wsplgen.h
   trunk/src/xy.cpp
   trunk/src/xy.h
Log:
Die Hheninterpolation von Linienobjekten wurde verbessert

Modified: trunk/src/file.cpp
===================================================================
--- trunk/src/file.cpp	2008-11-26 14:20:52 UTC (rev 136)
+++ trunk/src/file.cpp	2008-12-11 09:06:32 UTC (rev 137)
@@ -1827,7 +1827,7 @@
 			if (*L1 == 0x00000000L && *L2 == 0x7FF80000L)	Z = NoZ;
 			else											Z = psCShape->padfZ[j];
 
-			if (ShapeType == SHPT_ARC || ShapeType == SHPT_POLYGON || Z == NoZ)
+			if (ShapeType == SHPT_ARC || ShapeType == SHPT_ARCM || ShapeType == SHPT_POLYGON || ShapeType == SHPT_POLYGONM)
 			{
 				if (Typ == "DAMM")			Z = DammZ;
 				else if (Typ == "GRABEN")	Z = GrabenZ;
@@ -1836,7 +1836,8 @@
 
 			long XL = (long)(X * 100.0 + 0.5);
 			long YL = (long)(Y * 100.0 + 0.5);
-			int ZL = (int)(Z * 100.0 + 0.5);
+			int ZL = Z;
+			if (Z != NoZ) ZL = (int)(Z * 100.0 + 0.5);
 			Linie->AddPoint(XL, YL, ZL);
 		}
 
@@ -1844,6 +1845,11 @@
 
 		Count++;
 
+		if (ShapeType == SHPT_ARCZ || ShapeType == SHPT_POLYGONZ)
+		{
+			Linie->InterpolateZ();
+		}
+
 		if (DebugLevel >= 9 || (DebugLevel >= 1 && Count % 10 == 0) || (Count > 0 && Count % 100 == 0))
 		{
 			write_fortschritt("%d von %d Liniensstrukturen geladen.\n%d Sperren, %d Gräben, %d Rohre Tpy 1, %d Rohre Tpy 2\n", Count, RecordCount, SperrenList->size(), GrabenList->size(), Rohre1List->size(), Rohre2List->size());

Modified: trunk/src/test_xy.cpp
===================================================================
--- trunk/src/test_xy.cpp	2008-11-26 14:20:52 UTC (rev 136)
+++ trunk/src/test_xy.cpp	2008-12-11 09:06:32 UTC (rev 137)
@@ -25,15 +25,76 @@
 #ifdef __BORLANDC__
 #define POLYGONFILE		"test_daten\\test1.shp"
 #define PROFILFILE		"test_daten\\test1p.shp"
+#define LINIENFILE		"test_daten\\linien4.shp"
 #else
 #define POLYGONFILE		"test_daten/test1.shp"
 #define PROFILFILE		"test_daten/test1p.shp"
+#define LINIENFILE		"test_daten/linien4.shp"
 #endif
 
 //---------------------------------------------------------------------
 void test_xy(void)
 {
 	////////////////////////////////////////
+	// Test der Höheninterpolation
+	////////////////////////////////////////
+
+	printf ("*************************************************************************\n");
+	printf ("Test Höheninterpolation\n");
+
+	////////////////////////////////////////
+	// Zuerst Linien mit Z-Werten
+	////////////////////////////////////////
+
+	{
+		printf ("Test Z-Höheninterpolation:                                           ");
+
+		TProfilList *SperrenList = new TProfilList();
+		TProfilList *GrabenList = new TProfilList();
+		TProfilList *RohreList = new TProfilList();
+		TProfilList *GradientenList = new TProfilList();
+
+		LoadLinien(LINIENFILE, SperrenList, GrabenList, RohreList, GradientenList, false, 8);
+
+		long LineSum = 0;
+		for (TProfilList::iterator i = SperrenList->begin(); i != SperrenList->end(); i++)
+		{
+			TProfil* Line  = *i;
+
+			for (TPointList::iterator j = Line->PointList->begin(); j != Line->PointList->end(); j++)
+			{
+				TPoint* Point = *j;
+
+				int Z = Point->Z;
+
+				LineSum = LineSum + Z;
+			}
+		}
+
+		for (TProfilList::iterator i = GrabenList->begin(); i != GrabenList->end(); i++)
+		{
+			TProfil* Line  = *i;
+
+			for (TPointList::iterator j = Line->PointList->begin(); j != Line->PointList->end(); j++)
+			{
+				TPoint* Point = *j;
+
+				int Z = Point->Z;
+
+				LineSum = LineSum + Z;
+			}
+		}
+
+		if (LineSum != 62738)	printf("Failed\n");
+		else				 	printf("Pass\n");
+
+		delete SperrenList;
+		delete GrabenList;
+		delete RohreList;
+		delete GradientenList;
+	}
+
+	////////////////////////////////////////
 	// Test der Punktverwaltung
 	////////////////////////////////////////
 

Modified: trunk/src/wsplgen.h
===================================================================
--- trunk/src/wsplgen.h	2008-11-26 14:20:52 UTC (rev 136)
+++ trunk/src/wsplgen.h	2008-12-11 09:06:32 UTC (rev 137)
@@ -10,7 +10,7 @@
 // Read the file COPYING coming with WSPLGEN for details.
 //
 
-const char Version[] = "1.2.8";
+const char Version[] = "1.2.9";
 
 // In der Datei wsplgen.h wird jetzt keine Historie mehr gespeichert.
 // Diese ist nun in der Datei NEWS zu finden

Modified: trunk/src/xy.cpp
===================================================================
--- trunk/src/xy.cpp	2008-11-26 14:20:52 UTC (rev 136)
+++ trunk/src/xy.cpp	2008-12-11 09:06:32 UTC (rev 137)
@@ -2765,6 +2765,69 @@
 	return (false);
 }
 
+//---------------------------------------------------------------------------
+bool TProfil::InterpolateZ(void)
+{
+	write_fortschritt("->Interpolation der Höhen gestartet\n");
+
+	int VorZ = NoZ;
+	int VorM = 0;
+	TPointList::iterator VorIter = 0;
+
+	for (TPointList::iterator i = PointList->begin(); i != PointList->end(); i++)
+	{
+		TPoint* Point = *i;
+
+		int Z = Point->Z;
+		int M = Point->Meter;
+
+		if (Z != NoZ)
+		{
+			if (VorZ == NoZ)
+			{
+				// Am Anfang konstant
+				for (TPointList::iterator j = PointList->begin(); j != i; j++)
+				{
+					TPoint* Point = *j;
+					Point->Z = Z;
+				}
+			}
+			else
+			{
+				// In der Mitte interpoliert
+				for (TPointList::iterator j = VorIter; j != i; j++)
+				{
+					TPoint* Point = *j;
+					Point->Z = VorZ + (Z - VorZ) * (Point->Meter - VorM) / (M - VorM);
+				}
+			}
+			VorZ = Z;
+			VorM = M;
+			VorIter = i;
+		}
+	}
+
+	if (VorZ == NoZ)
+	{
+		write_fortschritt("<-Interpolation der Höhen beendet\n");
+
+		// Es sind alle Z-Höhen NOZ
+		return (false);
+	}
+	else
+	{
+		// Am Ende konstant
+		for (TPointList::iterator j = VorIter; j != PointList->end(); j++)
+		{
+			TPoint* Point = *j;
+			Point->Z = VorZ;
+		}
+		write_fortschritt("<-Interpolation der Höhen beendet\n");
+
+		return (true);
+	}
+}
+
 //---------------------------------------------------------------------
 // TProfilList
 //---------------------------------------------------------------------

Modified: trunk/src/xy.h
===================================================================
--- trunk/src/xy.h	2008-11-26 14:20:52 UTC (rev 136)
+++ trunk/src/xy.h	2008-12-11 09:06:32 UTC (rev 137)
@@ -377,6 +377,7 @@
 		double  		Length(TPoint *Point1, TPoint *Point2);
 		double  		Length(long X1, long Y1, long X2, long Y2);
 		TPoint*			FindNearest(long X, long Y);
+		bool 			InterpolateZ(void);
 };
 
 //----------------------------------------------------------------------------



More information about the Wsplgen-commits mailing list