Alexandre,<br><br>Can you send your code as a .cpp file as an attachment?<br>Also, I think you should change the line<br><span lang="EN-US">Buffer[size+1]=&#39;\0&#39;;<br>to<br></span><span lang="EN-US">Buffer[size]=&#39;\0&#39;;</span><br>
<br><div class="gmail_quote">On Thu, Mar 3, 2011 at 6:34 PM, Alexandre Leclerc <span dir="ltr">&lt;<a href="mailto:a.leclerc@valabre.com">a.leclerc@valabre.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div link="blue" vlink="purple" lang="FR"><div><p class="MsoNormal"><span lang="EN-US">Hello I try to draw a polygon from shapefile on geoconcept.</span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal">
<span lang="EN-US">But the points that I get are corrupted.</span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">Strangely a shapefile with no prj, and one ring in WGS84 works.</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">Here I try with a prj with lambert 2 extend projection.</span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal">
<span lang="EN-US">The shapefile contains 2 rings.</span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">See my code below.</span></p><p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal" style="text-indent: 35.4pt;"><span lang="EN-US">ifstream Prj;</span></p><p class="MsoNormal"><span lang="EN-US">                     Prj.open(PrjPath,ios::in);</span></p>
<p class="MsoNormal"><span lang="EN-US">                     if(Prj.is_open())                                                   </span></p><p class="MsoNormal"><span lang="EN-US">                     {</span></p><p class="MsoNormal">
<span lang="EN-US"> </span></p><p class="MsoNormal"><span style="color: rgb(0, 176, 80);" lang="EN-US">                        /*-----------read of PRJ--------------*/</span></p><p class="MsoNormal"><span lang="EN-US">                        Prj.seekg(0, ios::end);                                                  </span></p>
<p class="MsoNormal"><span lang="EN-US">                        int size = Prj.tellg();                                                   </span></p><p class="MsoNormal"><span lang="EN-US">                        Prj.seekg(0,ios::beg);                                                   </span></p>
<p class="MsoNormal"><span lang="EN-US">                        char *  Buffer = new char[size+1];</span></p><p class="MsoNormal"><span lang="EN-US">                        Prj.read(Buffer,size);</span></p><p class="MsoNormal">
<span style="color: rgb(0, 176, 80);" lang="EN-US">                        /*---------------------------------------*/</span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">                        Buffer[size+1]=&#39;\0&#39;;</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">                        OGRSpatialReference oSRS, oSRS2;</span></p><p class="MsoNormal"><span lang="EN-US">                        OGRCoordinateTransformation *poCT;</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">                        oSRS.importFromESRI(&amp;Buffer);</span></p><p class="MsoNormal"><span lang="EN-US">                        oSRS2.SetGeogCS( &quot;My geographic coordinate system&quot;,</span></p>
<p class="MsoNormal"><span lang="EN-US">                                        &quot;WGS_1984&quot;,</span></p><p class="MsoNormal"><span lang="EN-US">                                        &quot;My WGS84 Spheroid&quot;,</span></p>
<p class="MsoNormal"><span lang="EN-US">                                        SRS_WGS84_SEMIMAJOR, SRS_WGS84_INVFLATTENING,</span></p><p class="MsoNormal"><span lang="EN-US">                                        &quot;Greenwich&quot;, 0.0,</span></p>
<p class="MsoNormal"><span lang="EN-US">                                        &quot;degree&quot;, atoi(SRS_UA_DEGREE_CONV));</span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">                        poCT = OGRCreateCoordinateTransformation(&amp;oSRS,&amp;oSRS2);</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">                        if((poCT == NULL)||(poPoly-&gt;transform(poCT)!= </span>OGRERR_NONE))             <span style="color: rgb(0, 176, 80);">//Convert lambert 2 to WGS84</span></p>
<p class="MsoNormal">                        {</p><p class="MsoNormal">                         MessageBox(NULL,&quot;Erreur, Réessayez&quot;,&quot;Erreur&quot;,MB_ICONERROR);</p><p class="MsoNormal">                         <span lang="EN-US">PRJ = true;</span></p>
<p class="MsoNormal"><span lang="EN-US">                         return;</span></p><p class="MsoNormal"><span lang="EN-US">                        }</span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal">
<span lang="EN-US">                     }</span></p><p class="MsoNormal"><span lang="EN-US">                     Prj.close();</span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal" style="text-indent: 35.4pt;">
<span lang="EN-US">int nparts = poPoly-&gt;getNumInteriorRings();</span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">                   if(nparts==0)</span></p><p class="MsoNormal">
<span lang="EN-US">                      nparts = 1;</span></p><p class="MsoNormal"><span lang="EN-US">                      </span></p><p class="MsoNormal"><span lang="EN-US">                  for(int n=0;n&lt;nparts;n++)                                                           <span style="color: rgb(0, 176, 80);">//for npart…</span></span></p>
<p class="MsoNormal"><span lang="EN-US">                  {</span></p><p class="MsoNormal"><span lang="EN-US">                     OGRLinearRing *poRing;</span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal">
<span lang="EN-US">                      if(poPoly-&gt;getNumInteriorRings()&gt;0)                            <span style="color: rgb(0, 176, 80);">//if I understand correctly, through the function </span></span></p><p class="MsoNormal">
<span lang="EN-US">                        poRing = poPoly-&gt;getInteriorRing(n);                          <span style="color: rgb(0, 176, 80);">// OGRGeometryFactory::organizePolygons() of</span></span></p><p class="MsoNormal">
<span lang="EN-US">                      else                                                                                               <span style="color: rgb(0, 176, 80);">//SHPReadOGRObject, all the outer rings are converted in inner rings</span></span></p>
<p class="MsoNormal"><span lang="EN-US">                        poRing = poPoly-&gt;getExteriorRing();                            <span style="color: rgb(0, 176, 80);">//so if there is more rings than 0, there is many interior rings </span></span></p>
<p class="MsoNormal"><span style="color: rgb(0, 176, 80);" lang="EN-US">                                                                                                                             //else getInteriorRing(n) should be give the N rings</span></p>
<p class="MsoNormal"><span style="color: rgb(0, 176, 80);" lang="EN-US">                                                                                                                             //but the function gives one ring with one point which as an incorrect value  </span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">                     const LPXTNPOINT3D tabPoints = new XTNPOINT3D[poRing-&gt;getNumPoints()];        <span style="color: rgb(0, 176, 80);">//Tab of points for draw ring</span></span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">                     for(i=0;i&lt;poRing-&gt;getNumPoints();i++)                                                                                         <span style="color: rgb(0, 176, 80);">// Loop To Assign Points good projection</span></span></p>
<p class="MsoNormal"><span lang="EN-US">                     {</span></p><p class="MsoNormal"><span lang="EN-US">                        XTNPROJECTIONINFO xtnProjectionInfo = XtnStartMapProjection(xtnMapID);        <span style="color: rgb(0, 176, 80);">// Creating a projection for the coordinates</span></span></p>
<p class="MsoNormal"><span lang="EN-US">                        LPXTNPROJECTION lpxtnProjection = new XTNPROJECTION;                                            <span style="color: rgb(0, 176, 80);">//---------------------------------------------------------------</span></span></p>
<p class="MsoNormal"><span lang="EN-US">                        </span></p><p class="MsoNormal"><span lang="EN-US">                        lpxtnProjection-&gt;prLongitude = poRing-&gt;getX(i)*3.1415926535/180;                            <span style="color: rgb(0, 176, 80);">//Longitude point conversion in Projected</span></span></p>
<p class="MsoNormal"><span lang="EN-US">                        lpxtnProjection-&gt;prLatitude =  poRing-&gt;getY(i)*3.1415926535/180;                               <span style="color: rgb(0, 176, 80);">//Latitude--------------------------------------</span></span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">                        XtnProjection_Do(xtnProjectionInfo, lpxtnProjection);                                                       <span style="color: rgb(0, 176, 80);">//Projection conversion</span></span></p>
<p class="MsoNormal"><span lang="EN-US">                        XtnProjection_Destroy(xtnProjectionInfo);</span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">                        tabPoints[i].X =((long)((double)(lpxtnProjection-&gt;prX * 100.0 + 1.0))) / 100;          <span style="color: rgb(0, 176, 80);">//Conversion long</span></span></p>
<p class="MsoNormal"><span lang="EN-US">                        tabPoints[i].Y =((long)((double)(lpxtnProjection-&gt;prY * 100.0 + 1.0))) / 100;</span></p><p class="MsoNormal"><span lang="EN-US">                        tabPoints[i].Z = 0 ;</span></p>
<p class="MsoNormal"><span lang="EN-US">                     }</span></p><p class="MsoNormal"><span lang="EN-US">                     XtnGeom_SetPoints(MaForme,n,poRing-&gt;getNumPoints(),tabPoints);                      <span style="color: rgb(0, 176, 80);">// Insertion Points in the figure</span></span></p>
<p class="MsoNormal"><span lang="EN-US">                   }</span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">So, can you help me to fix my problem please ? </span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p><p class="MsoNormal"><span lang="EN-US">Sincerely.</span></p><p class="MsoNormal"> </p></div></div><br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br>
/tʃaɪθənjə/ /kʊmɑr/ <br>+91-9494447584<br>17.2416N 80.1426E<br>