<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=FR link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US>Hello I try to draw a polygon from shapefile on geoconcept.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>But the points that I get are corrupted.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Strangely a shapefile with no prj, and one ring in WGS84 works.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Here I try with a prj with lambert 2 extend projection.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>The shapefile contains 2 rings.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>See my code below.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='text-indent:35.4pt'><span lang=EN-US>ifstream Prj;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Prj.open(PrjPath,ios::in);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> if(Prj.is_open()) <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#00B050'> /*-----------read of PRJ--------------*/<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Prj.seekg(0, ios::end); <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> int size = Prj.tellg(); <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Prj.seekg(0,ios::beg); <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> char * Buffer = new char[size+1];<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Prj.read(Buffer,size);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#00B050'> /*---------------------------------------*/<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> Buffer[size+1]='\0';<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> OGRSpatialReference oSRS, oSRS2;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> OGRCoordinateTransformation *poCT;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> oSRS.importFromESRI(&Buffer);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> oSRS2.SetGeogCS( "My geographic coordinate system",<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> "WGS_1984",<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> "My WGS84 Spheroid",<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> SRS_WGS84_SEMIMAJOR, SRS_WGS84_INVFLATTENING,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> "Greenwich", 0.0,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> "degree", atoi(SRS_UA_DEGREE_CONV));<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> poCT = OGRCreateCoordinateTransformation(&oSRS,&oSRS2);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> if((poCT == NULL)||(poPoly->transform(poCT)!= </span>OGRERR_NONE)) <span style='color:#00B050'>//Convert lambert 2 to WGS84<o:p></o:p></span></p><p class=MsoNormal> {<o:p></o:p></p><p class=MsoNormal> MessageBox(NULL,"Erreur, Réessayez","Erreur",MB_ICONERROR);<o:p></o:p></p><p class=MsoNormal> <span lang=EN-US>PRJ = true;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> return;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Prj.close();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='text-indent:35.4pt'><span lang=EN-US>int nparts = poPoly->getNumInteriorRings();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> if(nparts==0)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> nparts = 1;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> for(int n=0;n<nparts;n++) <span style='color:#00B050'>//for npart…</span><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> OGRLinearRing *poRing;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> if(poPoly->getNumInteriorRings()>0) <span style='color:#00B050'>//if I understand correctly, through the function <o:p></o:p></span></span></p><p class=MsoNormal><span lang=EN-US> poRing = poPoly->getInteriorRing(n); <span style='color:#00B050'>// OGRGeometryFactory::organizePolygons() of</span><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> else <span style='color:#00B050'>//SHPReadOGRObject, all the outer rings are converted in inner rings<o:p></o:p></span></span></p><p class=MsoNormal><span lang=EN-US> poRing = poPoly->getExteriorRing(); <span style='color:#00B050'>//so if there is more rings than 0, there is many interior rings <o:p></o:p></span></span></p><p class=MsoNormal><span lang=EN-US style='color:#00B050'> //else getInteriorRing(n) should be give the N rings<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#00B050'> //but the function gives one ring with one point which as an incorrect value <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> const LPXTNPOINT3D tabPoints = new XTNPOINT3D[poRing->getNumPoints()]; <span style='color:#00B050'>//Tab of points for draw ring</span><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> for(i=0;i<poRing->getNumPoints();i++) <span style='color:#00B050'>// Loop To Assign Points good projection</span><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> XTNPROJECTIONINFO xtnProjectionInfo = XtnStartMapProjection(xtnMapID); <span style='color:#00B050'>// Creating a projection for the coordinates</span><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> LPXTNPROJECTION lpxtnProjection = new XTNPROJECTION; <span style='color:#00B050'>//---------------------------------------------------------------</span><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> lpxtnProjection->prLongitude = poRing->getX(i)*3.1415926535/180; <span style='color:#00B050'>//Longitude point conversion in Projected</span><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> lpxtnProjection->prLatitude = poRing->getY(i)*3.1415926535/180; <span style='color:#00B050'>//Latitude--------------------------------------</span><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> XtnProjection_Do(xtnProjectionInfo, lpxtnProjection); <span style='color:#00B050'>//Projection conversion</span><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> XtnProjection_Destroy(xtnProjectionInfo);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> tabPoints[i].X =((long)((double)(lpxtnProjection->prX * 100.0 + 1.0))) / 100; <span style='color:#00B050'>//Conversion long</span><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> tabPoints[i].Y =((long)((double)(lpxtnProjection->prY * 100.0 + 1.0))) / 100;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> tabPoints[i].Z = 0 ;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> XtnGeom_SetPoints(MaForme,n,poRing->getNumPoints(),tabPoints); <span style='color:#00B050'>// Insertion Points in the figure<o:p></o:p></span></span></p><p class=MsoNormal><span lang=EN-US> }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>So, can you help me to fix my problem please ? <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Sincerely.<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>