[Wsplgen-commits] r75 - trunk/src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat Nov 11 10:05:12 CET 2006


Author: mrchip
Date: 2006-11-11 10:05:11 +0100 (Sat, 11 Nov 2006)
New Revision: 75

Modified:
   trunk/src/file.cpp
   trunk/src/shape.cpp
   trunk/src/tools.cpp
   trunk/src/wsplgen.cpp
   trunk/src/wsplgen.h
   trunk/src/xy.cpp
Log:
Das Speichern von Elementen war v?\195?\182llig kaputt. 
Ein kleiner Fehler beim einschneiden der Gr?\195?\164ben und D?\195?\164mme wurde behoben, der zu L?\195?\182schern im Netz f?\195?\188hren konnte.

Modified: trunk/src/file.cpp
===================================================================
--- trunk/src/file.cpp	2006-10-25 22:00:50 UTC (rev 74)
+++ trunk/src/file.cpp	2006-11-11 09:05:11 UTC (rev 75)
@@ -2849,16 +2849,16 @@
 
 	if (Depth < TopoDiff)	Depth = TopoDiff;
 
-	long X1 = Node1->X;
-	long Y1 = Node1->Y;
-	long X2 = Node2->X;
-	long Y2 = Node2->Y;
-	long X3 = Node3->X;
-	long Y3 = Node3->Y;
+	double X1 = Node1->X / 100.0;
+	double Y1 = Node1->Y / 100.0;
+	double X2 = Node2->X / 100.0;
+	double Y2 = Node2->Y / 100.0;
+	double X3 = Node3->X / 100.0;
+	double Y3 = Node3->Y / 100.0;
 
-	long DoubleArea = X1 * Y2 - X2 * Y1 + X2 * Y3 - X3 * Y2 + X3 * Y1 - X1 * Y3;
+	double DoubleArea = X1 * Y2 - X2 * Y1 + X2 * Y3 - X3 * Y2 + X3 * Y1 - X1 * Y3;
 
-	if (DoubleArea < 0)
+	if (DoubleArea < 0.0)
 	{
 		SHPWriteElement(PolygonSHPHandle, X1, Y1, X2, Y2, X3, Y3);
 	}

Modified: trunk/src/shape.cpp
===================================================================
--- trunk/src/shape.cpp	2006-10-25 22:00:50 UTC (rev 74)
+++ trunk/src/shape.cpp	2006-11-11 09:05:11 UTC (rev 75)
@@ -551,7 +551,7 @@
 		psObject->dfMMin = psObject->dfMMax = psObject->padfM[0];
 	}
 
-    for(int i = 0; i < psObject->nVertices; i++ )
+	for (int i = 0; i < psObject->nVertices; i++)
 	{
 		if (psObject->dfXMin > psObject->padfX[i])	psObject->dfXMin = psObject->padfX[i];
 		if (psObject->dfYMin > psObject->padfY[i])	psObject->dfYMin = psObject->padfY[i];
@@ -573,31 +573,31 @@
 /************************************************************************/
 SHPObject SHPAPI_CALL1(*) SHPCreateObject( int nSHPType, int nShapeId, int nParts, int * panPartStart, int * panPartType, int nVertices, double * padfX, double * padfY, double * padfZ, double * padfM )
 {
-    SHPObject	*psObject;
-    int			i, bHasM, bHasZ;
+	SHPObject	*psObject;
+	int			i, bHasM, bHasZ;
 
 	psObject = (SHPObject *) SfCalloc(1, sizeof(SHPObject));
-    psObject->nSHPType = nSHPType;
-    psObject->nShapeId = nShapeId;
+	psObject->nSHPType = nSHPType;
+	psObject->nShapeId = nShapeId;
 
 	/* -------------------------------------------------------------------- */
 	/*	Establish whether this shape type has M, and Z values.		*/
 	/* -------------------------------------------------------------------- */
 	if (nSHPType == SHPT_ARCM || nSHPType == SHPT_POINTM || nSHPType == SHPT_POLYGONM || nSHPType == SHPT_MULTIPOINTM)
 	{
-        bHasM = TRUE;
-        bHasZ = FALSE;
-    }
+		bHasM = TRUE;
+		bHasZ = FALSE;
+	}
 	else if(nSHPType == SHPT_ARCZ || nSHPType == SHPT_POINTZ || nSHPType == SHPT_POLYGONZ || nSHPType == SHPT_MULTIPOINTZ || nSHPType == SHPT_MULTIPATCH)
 	{
-        bHasM = TRUE;
-        bHasZ = TRUE;
-    }
-    else
-    {
-        bHasM = FALSE;
-        bHasZ = FALSE;
-    }
+		bHasM = TRUE;
+		bHasZ = TRUE;
+	}
+	else
+	{
+		bHasM = FALSE;
+		bHasZ = FALSE;
+	}
 
 	/* -------------------------------------------------------------------- */
 	/*      Capture parts.  Note that part type is optional, and            */
@@ -778,7 +778,7 @@
 int SHPAPI_CALL SHPWriteElement(SHPHandle psSHP, double X1, double Y1, double X2, double Y2, double X3, double Y3)
 {
 	int		nRecordOffset, nRecordSize;
-	uchar	pabyRec[100];
+	uchar	pabyRec[120];
     int32	i32;
 
 	psSHP->bUpdated = TRUE;
@@ -818,47 +818,63 @@
 	if (YMax < Y2)	YMax = Y2;
 	if (YMax < Y3)	YMax = Y3;
 
-    ByteCopy (&XMin, pabyRec +  0, 8);
-    ByteCopy (&YMin, pabyRec +  8, 8);
-    ByteCopy (&XMax, pabyRec + 16, 8);
-    ByteCopy (&YMax, pabyRec + 24, 8);
+	ByteCopy (&XMin, pabyRec + 12, 8);        	// 12 - 19
+	ByteCopy (&YMin, pabyRec + 20, 8);         	// 20 - 27
+	ByteCopy (&XMax, pabyRec + 28, 8);         	// 28 - 35
+	ByteCopy (&YMax, pabyRec + 36, 8);        	// 36 - 43
 
-    if (bBigEndian)
-    {
-        Swap8Bytes (pabyRec + 12);				// 12 - 19
-        Swap8Bytes (pabyRec + 20);				// 20 - 27
-        Swap8Bytes (pabyRec + 28);				// 28 - 35
-        Swap8Bytes (pabyRec + 36);				// 36 - 43
-    }
+	if (bBigEndian)
+	{
+		Swap8Bytes (pabyRec + 12);
+		Swap8Bytes (pabyRec + 20);
+		Swap8Bytes (pabyRec + 28);
+		Swap8Bytes (pabyRec + 36);
+	}
 
-	int32 nPoints = 3;
-	int32 nParts = 0;
+	int32 nParts = 1;
+	int32 nPoints = 4;
 
-	if (bBigEndian) Swap4Bytes(&nPoints);
-	if (bBigEndian) Swap4Bytes(&nParts);
-
 	ByteCopy (&nParts, pabyRec + 44, 4);		// 44 - 47
-    ByteCopy (&nPoints, pabyRec + 48, 4);		// 48 - 51
+	ByteCopy (&nPoints, pabyRec + 48, 4);		// 48 - 51
+	if (bBigEndian) Swap4Bytes(pabyRec + 44);
+	if (bBigEndian) Swap4Bytes(pabyRec + 48);
 
-	ByteCopy (&X1, pabyRec + 52, 8 );			// 52 - 59
-	ByteCopy (&Y1, pabyRec + 60, 8 );			// 60 - 67
+	i32 = 0;
+	ByteCopy (&i32, pabyRec + 52, 4);			// 52 - 56	PanStart
+	if (bBigEndian) Swap4Bytes(pabyRec + 52);
 
-   	if (bBigEndian)	Swap8Bytes(pabyRec + 52);
-	if (bBigEndian)	Swap8Bytes(pabyRec + 60);
+	double X = 0.0;
+	double Y = 0.0;
 
-	ByteCopy(&X2, pabyRec + 68, 8 );			// 68 - 75
-	ByteCopy(&Y2, pabyRec + 76, 8 );			// 76 - 83
+	X = X1;
+	Y = Y1;
+	ByteCopy (&X, pabyRec + 56, 8);			// 56 - 63
+	ByteCopy (&Y, pabyRec + 64, 8);			// 64 - 72
+	if (bBigEndian)	Swap8Bytes(pabyRec + 56);
+	if (bBigEndian)	Swap8Bytes(pabyRec + 64);
 
-   	if (bBigEndian)	Swap8Bytes(pabyRec + 68);
-	if (bBigEndian)	Swap8Bytes(pabyRec + 76);
+	X = X2;
+	Y = Y2;
+	ByteCopy(&X, pabyRec + 72, 8);				// 72 - 79
+	ByteCopy(&Y, pabyRec + 80, 8);				// 80 - 87
+	if (bBigEndian)	Swap8Bytes(pabyRec + 72);
+	if (bBigEndian)	Swap8Bytes(pabyRec + 80);
 
-	ByteCopy (&X3, pabyRec + 84, 8 );			// 84 - 91
-	ByteCopy (&Y3, pabyRec + 92, 8 );			// 92 - 99
+	X = X3;
+	Y = Y3;
+	ByteCopy (&X, pabyRec + 88, 8);				// 88 - 95
+	ByteCopy (&Y, pabyRec + 96, 8);				// 96 - 103
+	if (bBigEndian)	Swap8Bytes(pabyRec + 88);
+	if (bBigEndian)	Swap8Bytes(pabyRec + 96);
 
-   	if (bBigEndian)	Swap8Bytes(pabyRec + 84);
-	if (bBigEndian)	Swap8Bytes(pabyRec + 92);
+	X = X1;
+	Y = Y1;
+	ByteCopy (&X, pabyRec + 104, 8);			// 104 - 111
+	ByteCopy (&Y, pabyRec + 112, 8);			// 112 - 119
+	if (bBigEndian)	Swap8Bytes(pabyRec + 104);
+	if (bBigEndian)	Swap8Bytes(pabyRec + 112);
 
-	nRecordSize = 100;
+	nRecordSize = 120;
 
 
 	/* -------------------------------------------------------------------- */
@@ -869,24 +885,24 @@
 
 	int nShapeId = psSHP->nRecords++;
 
-    psSHP->panRecOffset[nShapeId] = nRecordOffset = psSHP->nFileSize;
-    psSHP->panRecSize[nShapeId] = nRecordSize-8;
-    psSHP->nFileSize += nRecordSize;
+	psSHP->panRecOffset[nShapeId] = nRecordOffset = psSHP->nFileSize;
+	psSHP->panRecSize[nShapeId] = nRecordSize-8;
+	psSHP->nFileSize += nRecordSize;
 
 	/* -------------------------------------------------------------------- */
 	/*      Set the shape type, record number, and record size.             */
 	/* -------------------------------------------------------------------- */
 	i32 = nShapeId+1;						/* record # */
-    if (!bBigEndian) Swap4Bytes (&i32);
-    ByteCopy (&i32, pabyRec, 4);
+	ByteCopy (&i32, pabyRec + 0, 4);			// 0 - 3
+	if (!bBigEndian) Swap4Bytes (pabyRec + 0);
 
-    i32 = (nRecordSize-8)/2;				/* record size */
-    if (!bBigEndian) Swap4Bytes (&i32);
-    ByteCopy (&i32, pabyRec + 4, 4);
+	i32 = (nRecordSize-8)/2;				/* record size */
+	ByteCopy (&i32, pabyRec + 4, 4);		// 4 - 7
+	if (!bBigEndian) Swap4Bytes (pabyRec + 4);
 
-    i32 = SHPT_POLYGON;				/* shape type */
-    if (bBigEndian) Swap4Bytes(&i32);
-    ByteCopy (&i32, pabyRec + 8, 4);
+	i32 = SHPT_POLYGON;						/* shape type */
+	ByteCopy (&i32, pabyRec + 8, 4);		// 8 - 11
+	if (bBigEndian) Swap4Bytes (pabyRec + 8);
 
 	/* -------------------------------------------------------------------- */
 	/*      Write out record.                                               */
@@ -898,15 +914,17 @@
     }
 
 	/* -------------------------------------------------------------------- */
-	/*	Expand file wide bounds based on this shape.			*/
+	/*	Expand file wide bounds based on this shape.						*/
 	/* -------------------------------------------------------------------- */
-    if (psSHP->adBoundsMin[0] == 0.0 && psSHP->adBoundsMax[0] == 0.0 && psSHP->adBoundsMin[1] == 0.0 && psSHP->adBoundsMax[1] == 0.0)
+	if (psSHP->adBoundsMin[0] == 0.0 && psSHP->adBoundsMax[0] == 0.0 && psSHP->adBoundsMin[1] == 0.0 && psSHP->adBoundsMax[1] == 0.0)
     {
-        psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = X1;
-        psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = Y1;
-        psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = 0.0;
-        psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = 0.0;
-    }
+		psSHP->adBoundsMin[0] = XMin;
+		psSHP->adBoundsMin[1] = YMin;
+		psSHP->adBoundsMax[0] = XMax;
+		psSHP->adBoundsMax[1] = YMax;
+		psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = 0.0;
+		psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = 0.0;
+	}
 
 	if (psSHP->adBoundsMin[0] > XMin)	psSHP->adBoundsMin[0] = XMin;
 	if (psSHP->adBoundsMin[1] > YMin)	psSHP->adBoundsMin[1] = YMin;
@@ -979,8 +997,8 @@
 		if( bBigEndian ) Swap4Bytes(&nPoints );
 		if( bBigEndian ) Swap4Bytes(&nParts );
 
+		ByteCopy( &nParts, pabyRec + 36 + 8, 4 );
 		ByteCopy( &nPoints, pabyRec + 40 + 8, 4 );
-		ByteCopy( &nParts, pabyRec + 36 + 8, 4 );
 
 		nRecordSize = 52;
 
@@ -995,8 +1013,7 @@
 		// Write multipatch part types if needed.
 		if( psObject->nSHPType == SHPT_MULTIPATCH )
 		{
-			memcpy( pabyRec + nRecordSize, psObject->panPartType,
-                    4*psObject->nParts );
+			memcpy( pabyRec + nRecordSize, psObject->panPartType, 4*psObject->nParts );
             for( i = 0; i < psObject->nParts; i++ )
             {
                 if( bBigEndian ) Swap4Bytes(pabyRec + nRecordSize );
@@ -1040,7 +1057,7 @@
 
 		/*
          * Write the M values, if any.
-         */
+		*/
         if( psObject->nSHPType == SHPT_POLYGONM
             || psObject->nSHPType == SHPT_ARCM
 #ifndef DISABLE_MULTIPATCH_MEASURE            

Modified: trunk/src/tools.cpp
===================================================================
--- trunk/src/tools.cpp	2006-10-25 22:00:50 UTC (rev 74)
+++ trunk/src/tools.cpp	2006-11-11 09:05:11 UTC (rev 75)
@@ -127,8 +127,7 @@
 	if (strncmp(format, "<-", 2) == 0 && strlen(Indent) >= 2) Indent[strlen(Indent)-2] = '\0';
 
 	struct timeb Now;
-	ftime (&Now);
-
+	ftime (&Now);
 	long Secs;
 	long Mins;
 	long Hours;
@@ -150,8 +149,7 @@
 void GetTimeAndDate(long *Secs, long *Mins, long *Hours, long *Days, long *Months, long *Years)
 {
 	struct timeb Now;
-	ftime (&Now);
-
+	ftime (&Now);
 	*Secs = Now.time;
 	*Mins = *Secs  / 60;
 	*Secs = *Secs - *Mins * 60;
@@ -2327,29 +2325,6 @@
 			else                            Node->Wsp = SaveNode->Wsp;
 		}
 
-		if (DebugLevel >= 2)	write_fortschritt("Maximalen Wasserstand ermitteln\n");
-
-		// Maximalen Wasserstand ermitteln
-		double  MaxWsp = 0.0;
-		for (TNodeList::iterator i = NodeList->begin(); i != NodeList->end(); i++)
-		{
-			TNode *Node = *i;
-
-			if (i == NodeList->begin() || MaxWsp < Node->Wsp)   MaxWsp = Node->Wsp;
-		}
-
-		if (DebugLevel >=2)	write_fortschritt("Sicher trockene Knoten ermitteln\n");
-
-		// Anzahl der Knoten bestimmen, die höher als der maximale Wassrstand sind
-		// oder die schon einen Wasserstand haben
-		int Ready = 0;
-		for (TNodeList::iterator i = NodeList->begin(); i != NodeList->end(); i++)
-		{
-			TNode *Node = *i;
-
-			if (Node->Wsp != NoWsp || Node->Z > MaxWsp)  Ready++;
-		}
-
 		if (DebugLevel >= 2)	write_fortschritt("Erste Kanten mit Nass/Trocken-Übergang ermitteln\n");
 
 		// Die Kanten bestimmen, die an einem Ende einen nassen und am anderen Ende einen trockenen Knoten haben
@@ -2373,11 +2348,8 @@
 
 		TEdgeList *TempEdgeList = new TEdgeList();
 		int Changed = 0;
-		int Run = 0;
 		do
 		{
-			Run++;
-
 			if (RohreList->size() > 0)
 			{
 				// Jetzt den Wasserstand aus der NodeList extrahieren
@@ -2396,8 +2368,6 @@
 				TransferWspFromGradient(GradientenList, NodeList, Temp2EdgeList, AvgDistance * 2.0, DebugLevel);
 			}
 
-			// if (Run % 10 == 0)	write_fortschritt("Durchlauf %d\n", Run);
-
 			// Hier nur die Verwaltungsinformationen, aber nicht die richtigen Kanten löschen
 			// Es waren nur geliehene Kanten
 			TempEdgeList->Empty();
@@ -2430,7 +2400,7 @@
 				{
 					if (Edge->Node2->Wsp <= Edge->Node2->Z)
 					{
-						dump_error(__FILE__, __LINE__, "Ein Knoten Kantenendknoten %d ist unter Gelände aber nass", Edge->Node2->Nr);
+						dump_error(__FILE__, __LINE__, "Der Kantenendknoten %d ist unter Gelände aber nass", Edge->Node2->Nr);
 					}
 
 					Edge->Node1->Wsp = Edge->Node2->Wsp;
@@ -2452,7 +2422,7 @@
 				{
 					if (Edge->Node1->Wsp <= Edge->Node1->Z)
 					{
-						dump_error(__FILE__, __LINE__, "Ein Knoten Kantenstartknoten %d ist unter Gelände aber nass", Edge->Node1->Nr);
+						dump_error(__FILE__, __LINE__, "Der Kantenstartknoten %d ist unter Gelände aber nass", Edge->Node1->Nr);
 					}
 
 					Edge->Node2->Wsp = Edge->Node1->Wsp;
@@ -2471,9 +2441,6 @@
 					Changed++;
 				}
 			}
-
-			Ready = Ready + Changed;
-
 		} while (Changed > 0);
 
 		// Hier nur die Verwaltungsinformationen, aber nicht die richtigen Kanten löschen

Modified: trunk/src/wsplgen.cpp
===================================================================
--- trunk/src/wsplgen.cpp	2006-10-25 22:00:50 UTC (rev 74)
+++ trunk/src/wsplgen.cpp	2006-11-11 09:05:11 UTC (rev 75)
@@ -97,6 +97,12 @@
 	// (und an andere Klassen in Form von Pointern ausgeliehen)
 	TNodeList* NodeList = new TNodeList();
 
+	// Hier werden die Elemente drin verwaltet
+	// Die Elemente werden aus ausgeliehenen Knoten gebildet
+	// Daher muss man immer erst die Knoten einlesen und dann die Elemente
+	// Eigentlich braucht man die Elemente nicht
+	TElementList *ElementList = new TElementList;
+
 	// Hier werden die Gewaesserachsen drin verwaltet
 	TGewaesserAchseList GewaesserAchseList;
 
@@ -174,12 +180,6 @@
 		std::string PolygonFileName = ExchangeFileExt(Parameter.FileNameAusgabe, "_begrenzungspolygon.shp");
 		SavePolygon(PolygonFileName, BegrenzungsPolygon, Parameter.DebugLevel);
 
-		// Hier werden die Elemente drin verwaltet
-		// Die Elemente werden aus ausgeliehenen Knoten gebildet
-		// Daher muss man immer erst die Knoten einlesen und dann die Elemente
-		// Eigentlich braucht man die Elemente nicht
-		TElementList *ElementList = new TElementList;
-
 		LoadDGM(Parameter.FileNameDgm, NodeList, ElementList, BegrenzungsPolygon, Parameter.DebugLevel);
 
 		// Wenn die Elementliste noch leer ist, müssen die Knoten noch trianguliert werden.

Modified: trunk/src/wsplgen.h
===================================================================
--- trunk/src/wsplgen.h	2006-10-25 22:00:50 UTC (rev 74)
+++ trunk/src/wsplgen.h	2006-11-11 09:05:11 UTC (rev 75)
@@ -10,8 +10,16 @@
 // Read the file COPYING coming with WSPLGEN for details.
 //
 
-const char Version[] = "1.0.0 rc2";
+const char Version[] = "1.0.0 rc3";
 
+// Die Koordinaten der Elemente waren um den Faktor 100 zu gross
+
+// Das Dateiformat für die Elemente war völlig kaputt
+
+// Ein Fehler beim Einscheiden von Dämmen oder Gräben wurde behoben
+
+// const char Version[] = "1.0.0 rc2";
+
 // Eine Erkennung von doppelten Punkten in Begrenzungpolygonen wurde eingeführt.
 // Damit bricht WSPLGEN nicht mehr ab, wenn es solche Situationen findet. 
 

Modified: trunk/src/xy.cpp
===================================================================
--- trunk/src/xy.cpp	2006-10-25 22:00:50 UTC (rev 74)
+++ trunk/src/xy.cpp	2006-11-11 09:05:11 UTC (rev 75)
@@ -1577,7 +1577,7 @@
 			NewElement->Typ	= NEWTRI;
 			push_back(NewElement);
 
-			NewElement = new TElement(Node2, Node23, Node3);
+			NewElement = new TElement(Node1, Node23, Node3);
 			NewElement->Typ	= NEWTRI;
 			push_back(NewElement);
 



More information about the Wsplgen-commits mailing list