<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1476" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=930444419-16102004><FONT face=Arial color=#0000ff size=2>Ok, I
figured it out. I had numerous things wrong in my code outside this
function. I still have one problem though. The Transform method of
the <SPAN class=306072117-14102004><FONT
color=#000000>OGRCoordinateTransformation class doesn't like it when I pass in
coordinates that are outside the valid limit for certain projections (i.e.
Mercator). My new question is, how do I calculate what the valid limits
are for a projection like mercator? Is it a matter of subtracting False
Easting and Northing or something like that? Any help on understanding how
to calculate these limits for a projection would be much
appreciated.</FONT></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=930444419-16102004><FONT face=Arial color=#000000 size=2><SPAN
class=306072117-14102004></SPAN></FONT></SPAN> </DIV>
<DIV><SPAN class=930444419-16102004><FONT face=Arial color=#000000 size=2><SPAN
class=306072117-14102004>Thanks,</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=930444419-16102004><FONT face=Arial color=#000000 size=2><SPAN
class=306072117-14102004>Martin</SPAN></FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> Chapman, Martin
<BR><B>Sent:</B> Thursday, October 14, 2004 11:42 AM<BR><B>To:</B>
gdal-dev@remotesensing.org<BR><B>Subject:</B> [Gdal-dev] Coordinate transform
problem<BR><BR></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=306072117-14102004>I recently
switched my projection support from Proj4 to OGR and I'm having some issues
when using the OGRCoordinateTransformation object. Basically, it looks
like not all of my points are being transformed correctly when converting from
one projection to the other. (ie. AEA to MERC). I check for errors
when converting but no errors are being thrown. Basically my code looks
like this:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=306072117-14102004></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=306072117-14102004>OGRCoordinateTransformation* pCT =
NULL;<BR> pCT = OGRCreateCoordinateTransformation(&sourceSRS,
&targetSRS);<BR> if ((CPLGetLastErrorNo() != OGRERR_NONE) ||
(!pCT)) throw (char*) CPLGetLastErrorMsg();</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=306072117-14102004> if
(pGeometry->GetGeometryTypeId() ==
VPWkbPolygon)<BR> {<BR> CVPPtr< IVPPolygon>
spPolygon = (IVPPolygon*)
pGeometry;<BR> spPolygon->GetExteriorRing()->GetCoords(&pXCoords,
&pYCoords);</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=306072117-14102004> vector< double>* pNewXCoords
= new vector< double>(*pXCoords);<BR> vector<
double>* pNewYCoords = new vector<
double>(*pYCoords);<BR> if (pCT->Transform((int)
pNewXCoords->size(), &(*pNewXCoords)[0],
&(*pNewYCoords)[0]))<BR> ((CVPLinearRing*)(spPolygon.p->GetExteriorRing()))->SetCoords(pNewXCoords,
pNewYCoords);</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=306072117-14102004> for (int i = 0; i <
spPolygon->GetNumInteriorRing();
i++)<BR> {<BR> spPolygon->GetInteriorRingN(i)->GetCoords(&pXCoords,
&pYCoords);<BR> vector< double>* pNewXCoords
= new vector< double>(*pXCoords);<BR> vector<
double>* pNewYCoords = new vector<
double>(*pYCoords);<BR> if (pCT->Transform((int)
pNewXCoords->size(), &(*pNewXCoords)[0],
&(*pNewYCoords)[0]))<BR> ((CVPLinearRing*)(spPolygon.p->GetInteriorRingN(i)))->SetCoords(pNewXCoords,
pNewYCoords);<BR> }<BR> }</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=306072117-14102004> if
(pCT) delete pCT;</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=306072117-14102004></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=306072117-14102004>I understand that
some projections have valid lat/lon ranges that can be less than others
(ie. Merc vs. latlong), should I not be passing points that are greater than a
certain range? I was thinking that the proj library would wrap any
longitudes if they needed wrapping. Is this a wrong assumption?
Can anyone see what I'm doing wrong. I've attached a screen shot to show
what the half/baked transform looks like when converting from AEA to MERC, and
the .prj files I'm using for the projection info...I load them using
importFromESRI(). Also, I'm using GDAL 1.19. I know you're going
to say upgrade...ok, I'll get on that.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=306072117-14102004></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=306072117-14102004>Thanks for any
help!</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=306072117-14102004></SPAN></FONT> </DIV>
<DIV align=left><FONT face=Arial size=2>
<DIV align=left><FONT face=Arial size=2>Martin Chapman</FONT></DIV>
<DIV align=left><FONT face=Arial><FONT size=2><SPAN
class=812572720-02042003>Cell</SPAN> 303-885-1936</FONT></FONT></DIV>
<DIV align=left><FONT face=Arial size=2><SPAN class=812572720-02042003>Office
303-495-6300 x326</SPAN></FONT></DIV>
<DIV align=left><FONT face=Arial size=2><SPAN class=812572720-02042003><A
href="mailto:mchapman@sanz.com">mchapman@sanz.com</A></SPAN></FONT></DIV>
<DIV align=left><FONT face=Arial size=2><SPAN class=812572720-02042003><A
href="http://www.sanz.com/">http://www.sanz.com</A></SPAN></FONT></DIV></FONT></DIV>
<DIV align=left><FONT face=Arial size=2></FONT> </DIV>
<DIV> </DIV></BLOCKQUOTE></BODY></HTML>