MapTools.org

[Shapelib] shapefile: cant read out

shapelib@lists.maptools.org shapelib@lists.maptools.org
Fri, 12 Mar 2004 17:27:30 +0100
Hi,
what i try, my project stoped whitout reason. I try the follow :

//////////////////////////////////////////////////////////////////////
// Memberfunktionen
//////////////////////////////////////////////////////////////////////
void CConverter::drawPolyLine(const SHPObject& obj)
{
	// wieviele Teile?
	for(int i=0; i < obj.nVertices;i++)
	{
		// linie Zeichenen (dabei Konvertierung und Skalierung
		// der unterschiedlichen Koordinatensysteme)
		m_shapeView->DrawLine((int)(obj.padfX[i]),
					    (int)((obj.padfY[i]),
					    (int)(obj.padfX[i+1]),
					    (int)((obj.padfY[i+1]),
					    0xFF0000);
	}
}


bool CConverter::PaintObjects()
{
	// Wieviel Objekte gibt es in der Datei (shapefile),
	int nEntities = 0;
	// max Werte werden für die Berechnung gebraucht (siehe draw Funktionen)
	SHPGetInfo(m_shapeFile,&nEntities,NULL,m_min,m_max);
	// Image anlegen
	m_shapeView->Create(m_max[0],m_max[1],24,TIF);

	SHPObject* shObject;
	// Objekte in der Datei?
	if(nEntities>0)
	{
		// alle Objekte zeichnen
		for (int i = 0; i<nEntities; i++)
		{
			// Objekt auslesen
			shObject = SHPReadObject(m_shapeFile,i);
			// Welchen Typ hat die Datei -> Zeichenoperation wählen
			switch(shObject->nSHPType)
			{
				// Punkte
			case 3:drawPolyLine(*shObject);break;
			default:AfxMessageBox("Unsupportet shapetyp");
			}
		}
		m_shapeView->Save("testbild.tif",CXIMAGE_FORMAT_TIF);
		return true;
	}
	else
		return false;
}

If i start my program whit this function it never come to an end.
I think it is the first function who is wrong because if i replace the
i<nVertices whit i<nParts it works, but i get false picture. I know the
source (shp) is right.

Someone know what i have to do that it works?

PS: i try it some hours ;(

best regards
Michael



This archive was generated by Pipermail.