[gdal-dev] Polygon

2011-03-03 Thread Alexandre Leclerc
Hello I try to draw a polygon from shapefile on geoconcept.

 

But the points that I get are corrupted.

 

Strangely a shapefile with no prj, and one ring in WGS84 works.

 

Here I try with a prj with lambert 2 extend projection.

 

The shapefile contains 2 rings.

 

See my code below.

 

 

ifstream Prj;

 Prj.open(PrjPath,ios::in);

 if(Prj.is_open())


 {

 

/*---read of PRJ--*/

Prj.seekg(0, ios::end);


int size = Prj.tellg();


Prj.seekg(0,ios::beg);


char *  Buffer = new char[size+1];

Prj.read(Buffer,size);

/*---*/

 

Buffer[size+1]='\0';

 

OGRSpatialReference oSRS, oSRS2;

OGRCoordinateTransformation *poCT;

 

oSRS.importFromESRI(&Buffer);

oSRS2.SetGeogCS( "My geographic coordinate system",

"WGS_1984",

"My WGS84 Spheroid",

SRS_WGS84_SEMIMAJOR,
SRS_WGS84_INVFLATTENING,

"Greenwich", 0.0,

"degree", atoi(SRS_UA_DEGREE_CONV));

 

poCT =
OGRCreateCoordinateTransformation(&oSRS,&oSRS2);

 

 

if((poCT == NULL)||(poPoly->transform(poCT)!=
OGRERR_NONE)) //Convert lambert 2 to WGS84

{

 MessageBox(NULL,"Erreur,
Réessayez","Erreur",MB_ICONERROR);

 PRJ = true;

 return;

}

 

 }

 Prj.close();

 

int nparts = poPoly->getNumInteriorRings();

 

   if(nparts==0)

  nparts = 1;

  

  for(int n=0;ngetNumInteriorRings()>0)
//if I understand correctly, through the function 

poRing = poPoly->getInteriorRing(n);
// OGRGeometryFactory::organizePolygons() of

  else
//SHPReadOGRObject, all the outer rings are converted in inner rings

poRing = poPoly->getExteriorRing();
//so if there is more rings than 0, there is many interior rings 

 
//else getInteriorRing(n) should be give the N rings

 
//but the function gives one ring with one point which as an incorrect value


 

 const LPXTNPOINT3D tabPoints = new
XTNPOINT3D[poRing->getNumPoints()];//Tab of points for draw ring

 

 for(i=0;igetNumPoints();i++)
// Loop To Assign Points good projection

 {

XTNPROJECTIONINFO xtnProjectionInfo =
XtnStartMapProjection(xtnMapID);// Creating a projection for the
coordinates

LPXTNPROJECTION lpxtnProjection = new XTNPROJECTION;
//---



lpxtnProjection->prLongitude =
poRing->getX(i)*3.1415926535/180;//Longitude
point conversion in Projected

lpxtnProjection->prLatitude =
poRing->getY(i)*3.1415926535/180;
//Latitude--

 

XtnProjection_Do(xtnProjectionInfo,
lpxtnProjection);
//Projection conversion

XtnProjection_Destroy(xtnProjectionInfo);

 

tabPoints[i].X
=((long)((double)(lpxtnProjection->prX * 100.0 + 1.0))) / 100;
//Conversion long

tabPoints[i].Y
=((long)((double)(lpxtnProjection->prY * 100.0 + 1.0))) / 100;

tabPoints[i].Z = 0 ;

 }

 
XtnGeom_SetPoints(MaForme,n,poRing->getNumPoints(),tabPoints);
// Insertion Points in the figure

   }

 

 

So, can you help me to fix my problem please ? 

 

Sincerely.

 

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

[gdal-dev] Polygon(suite)

2011-03-03 Thread Alexandre Leclerc
Sorry, I forgot to tell you that I used SHPReadOGRObject for read the
SHPObject.

 

put it at the beginning of the code of previous mail

 

SHPHandle  hSHP = SHPOpen(chemin.c_str(),"rb");

SHPObject  *psShape = SHPReadObject(hSHP,0);

OGRGeometry *poPoly = SHPReadOGRObject(hSHP, 0,psShape);

 

 

Sincerly

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

RE: [gdal-dev] Polygon

2011-03-04 Thread Alexandre Leclerc
Anybody can help me please ? 

 

I feel that the SHPWriteObject()  write a bad way in the file.

 

Do you think it could come from compiler ? I use Borland C++ 6

 

When I edit the file in text editor it seems good, the length of the file is
1904

 

But when I read file with SHPOpen() the psSHP->nFileSize attribute is 100.
oddly this corresponds to the size of the header (shx).

 

So I wonder if It comes from compiler or not. 

 

What do you think ?

 

Here in shpOpen().

 

/*  */

/*  Read the file size from the SHP file.
*/

/*  */

pabyBuf = (uchar *) malloc(100);

psSHP->sHooks.FRead( pabyBuf, 100, 1, psSHP->fpSHP );

 

psSHP->nFileSize = ((unsigned int)pabyBuf[24] * 256 * 256 * 256

   + (unsigned int)pabyBuf[25] *
256 * 256

   + (unsigned int)pabyBuf[26] *
256

   + (unsigned int)pabyBuf[27])
* 2;

 

 

Only papybuf[27] has a value (50) , others have 0 as value..

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

[gdal-dev] c# P/invoke error spatialRef

2012-01-09 Thread Alexandre LECLERC
Hello, 

I try to transform coordinates between 2 projections.

But when I pass this line : 

SpatialReference spaceRef1 = new SpatialReference("");

I get a P/Invoke exception...

I've downloaded  the FWtools 247

I've add to my project all the dll in the directory C:\ Program Files (x86)
\FWTools2.4.6\csharp

I add in the path C:\Program Files (x86)\FWTools\bin

 

Can you help me please ?

 

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev