<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>OGR OCI Driver improvement about CoordinateDimension</TITLE>
<META content="MSHTML 6.00.2900.5726" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=976371510-20082009><FONT face=Arial><FONT color=#0000ff><FONT
size=2>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">Hello,</SPAN><SPAN
lang=EN-GB
style="FONT-FAMILY: 'Arial Unicode MS'; mso-ansi-language: EN-GB"><?xml:namespace
prefix = o ns = "urn:schemas-microsoft-com:office:office"
/><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="mso-ansi-language: EN-GB"><FONT size=3><FONT color=#000000><FONT
face="Times New Roman"> <o:p></o:p></FONT></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">
I've installed my Python environment successfully. Now I would like to
test the autotest </SPAN><SPAN lang=EN-GB
style="mso-ansi-language: EN-GB"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="mso-ansi-language: EN-GB"><FONT size=3><FONT color=#000000><FONT
face="Times New Roman"> <o:p></o:p></FONT></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">
</SPAN><SPAN lang=FR-BE style="mso-ansi-language: FR-BE"><A
href="http://svn.osgeo.org/gdal/trunk/autotest/ogr/ogr_oci.py"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">http://svn.osgeo.org/gdal/trunk/autotest/ogr/ogr_oci.py</SPAN></A></SPAN><SPAN
lang=EN-GB style="mso-ansi-language: EN-GB"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="mso-ansi-language: EN-GB"><FONT size=3><FONT color=#000000><FONT
face="Times New Roman"> <o:p></o:p></FONT></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">
but in the function ogr_oci_10() the 'expected_wkt' include a third
dimension for a 2D feature. Think that I would like to fixe with my
patches.</SPAN><SPAN lang=EN-GB
style="mso-ansi-language: EN-GB"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="mso-ansi-language: EN-GB"><FONT size=3><FONT color=#000000><FONT
face="Times New Roman"> <o:p></o:p></FONT></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">
so I would like to replace </SPAN><SPAN lang=EN-GB
style="mso-ansi-language: EN-GB"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">
expected_wkt = 'POLYGON ((1 1 0,5 1 0,5 7 0,1 7 0,1 1 0))' </SPAN><SPAN
lang=EN-GB style="mso-ansi-language: EN-GB"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">
by</SPAN><SPAN lang=EN-GB
style="mso-ansi-language: EN-GB"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">
expected_wkt = 'POLYGON ((1 1,5 1,5 7,1 7,1 1))'</SPAN><SPAN lang=EN-GB
style="FONT-FAMILY: Arial; mso-ansi-language: EN-GB"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> Which
is beter for a 2D geometry.</SPAN><SPAN lang=EN-GB
style="FONT-FAMILY: Arial; mso-ansi-language: EN-GB"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-FAMILY: Arial; mso-ansi-language: EN-GB"><FONT size=3><FONT
color=#000000> <o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> Is
this change wished or does it create incompatibilities ? </SPAN><SPAN
lang=EN-GB
style="FONT-FAMILY: Arial; mso-ansi-language: EN-GB"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-FAMILY: Arial; mso-ansi-language: EN-GB"><FONT size=3><FONT
color=#000000> <o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">
nb. This is also the case in ogr_oci_14() for LINESTRING and in
ogr_oci_15().</SPAN><SPAN lang=EN-GB
style="FONT-FAMILY: Arial; mso-ansi-language: EN-GB"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-FAMILY: Arial; mso-ansi-language: EN-GB"><FONT size=3><FONT
color=#000000> <o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">
By the way, is there an svn access to autotest ?</SPAN><SPAN lang=EN-GB
style="FONT-FAMILY: Arial; mso-ansi-language: EN-GB"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-FAMILY: Arial; mso-ansi-language: EN-GB"><FONT size=3><FONT
color=#000000> <o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">
</SPAN><SPAN lang=FR-BE
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-ansi-language: FR-BE">Nicolas</SPAN><SPAN
lang=FR-BE
style="FONT-FAMILY: Arial; mso-ansi-language: FR-BE"><o:p></o:p></SPAN></P></FONT></FONT></FONT></DIV>
<DIV></SPAN><FONT face=Tahoma size=2>-----Message
d'origine-----<BR><B>De :</B> Nicolas Simon <BR><B>Envoyé :</B>
mercredi 5 août 2009 17:04<BR><B>À :</B> Nicolas
Simon<BR><B>Objet :</B> RE: [gdal-dev] OGR OCI Driver improvement about
CoordinateDimension<BR><BR></FONT></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV><SPAN class=366574814-05082009><FONT face=Arial color=#0000ff size=2>Hi
all,</FONT></SPAN></DIV>
<DIV><SPAN class=366574814-05082009> <FONT face=Arial
color=#0000ff size=2>I provide a patch file against main trunk to solve the
second point (read interpretation), attached with Ticket #3025 (file
OCIRead3025.diff)</FONT></SPAN></DIV>
<DIV><SPAN class=366574814-05082009><FONT face=Arial color=#0000ff
size=2></FONT></SPAN><SPAN class=366574814-05082009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=366574814-05082009><FONT face=Arial color=#0000ff
size=2> Can anyone who use Oracle can provide me a feedback
?</FONT></SPAN></DIV>
<DIV><SPAN class=366574814-05082009><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=366574814-05082009> <FONT face=Arial
color=#0000ff size=2>Thanks.</FONT></SPAN></DIV>
<DIV><SPAN class=366574814-05082009><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=366574814-05082009> <FONT face=Arial
color=#0000ff size=2>Nicolas</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Message d'origine-----<BR><B>De :</B>
gdal-dev-bounces@lists.osgeo.org
[mailto:gdal-dev-bounces@lists.osgeo.org]<B>De la part de</B> Nicolas
Simon<BR><B>Envoyé :</B> mercredi 5 août 2009 14:55<BR><B>À :</B>
gdal-dev@lists.osgeo.org<BR><B>Objet :</B> [gdal-dev] OGR OCI Driver
improvement about CoordinateDimension<BR><BR></FONT></DIV><!-- Converted from text/rtf format -->
<P><SPAN lang=fr-be><FONT face="Times New Roman">Dear
developpers,</FONT></SPAN><SPAN lang=fr-be></SPAN><SPAN lang=fr-be>
</SPAN></P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">This problem is not
actually well handled when we use feature with 2D and 3D
coordinate.</FONT></SPAN> <BR><SPAN lang=fr-be><FONT
face="Times New Roman">(I provide test file with Ticket #3025)
</FONT></SPAN></P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">1) When we WRITE data into
Oracle, TranslateTOSDOGeometry() and TranslateElemGroup()</FONT></SPAN>
<BR><SPAN lang=fr-be><FONT face="Times New Roman"> use
nDimension member variable of OCIWritableLayer to handle the
translation.</FONT></SPAN> <BR><SPAN lang=fr-be><FONT
face="Times New Roman"> Unfortunaly nDimension initisation
is</FONT></SPAN> <BR><SPAN lang=fr-be><FONT
face="Times New Roman"> nDimension =
MAX(2,MIN(3,atoi(CPLGetConfigOption("OCI_DEFAULT_DIM","3"))));</FONT></SPAN>
<BR><SPAN lang=fr-be><FONT face="Times New Roman"> which is good
when creating layer but not if we update feature table and</FONT></SPAN>
<BR><SPAN lang=fr-be><FONT face="Times New Roman"> if we have
different feature table with different dimension </FONT></SPAN><BR><SPAN
lang=fr-be><FONT face="Times New Roman"> (OCI_DEFAULT_DIM cannot
be set to handle both 2D and 3D simultanously). </FONT></SPAN></P>
<P><SPAN lang=fr-be><FONT face="Times New Roman"> The solution
is to query ALL_SDO_GEOM_METADATA to get the dimension of existing table
and</FONT></SPAN> <BR><SPAN lang=fr-be><FONT
face="Times New Roman"> overwrite the default
value.</FONT></SPAN> </P>
<P><SPAN lang=fr-be><FONT face="Times New Roman"> The best place
I found to put this check is in OGROCITableLayer::ReadTableDefinition()
because it does not concern OGROCILoaderLayer.</FONT></SPAN></P>
<P><SPAN lang=fr-be><FONT face="Times New Roman"> I attach the
patch to Ticket #3025 (file is OCIWrite3025.diff )</FONT></SPAN>
<BR><SPAN lang=fr-be><FONT face="Times New Roman">
</FONT></SPAN><BR><SPAN lang=fr-be><FONT face="Times New Roman">2) When we
READ data from Oracle, TranslateGeometry() and TranslateGeometryElement()
take the dimension</FONT></SPAN> <BR><SPAN lang=fr-be><FONT
face="Times New Roman"> from Gtype of the SDO_GEOMETRY (That's
right).</FONT></SPAN> <BR><SPAN lang=fr-be><FONT face="Times New Roman">The
dimension is well used in decoding sdo_ordinates (see GetOrdinalPoint for
exemple).</FONT></SPAN> <BR><SPAN lang=fr-be><FONT
face="Times New Roman">The problem is when we create OGRGeometry because it
always construct 3D geometry even if we have 2D geometry. </FONT></SPAN></P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">For exemple (in
TranslateGeometryElement())</FONT></SPAN> </P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">
...</FONT></SPAN> <BR><SPAN lang=fr-be><FONT
face="Times New Roman"> double dfX, dfY, dfZ =
0.0;</FONT></SPAN> </P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">
GetOrdinalPoint( nStartOrdinal, nDimension, &dfX, &dfY, &dfZ
);</FONT></SPAN> </P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">
poPoint->setX( dfX );</FONT></SPAN> <BR><SPAN lang=fr-be><FONT
face="Times New Roman"> poPoint->setY( dfY
);</FONT></SPAN> <BR><SPAN lang=fr-be><FONT
face="Times New Roman"> poPoint->setZ( dfZ );
</FONT></SPAN></P>
<P><SPAN lang=fr-be><FONT face="Times New Roman"> Many strategies exist
to fix this problem.</FONT></SPAN> </P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">The simplest one is to
force to 2D if dimension = 2 before returning from TranslateGeometry() but
this solution does a lot of extra work (building a dummy 3D and deleting the
3rd dimension)</FONT></SPAN></P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">To apply this solution a
call to Flatten2D maintains the Z dimention but set it to 0. Not the
solution I would like => Bad solution</FONT></SPAN></P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">An other way is to call
setCoordinateDimension() but the doc says "Setting the dimension of a
geometry collection will not necessarily affect the children geometries.".
Not a definitive solution.</FONT></SPAN></P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">My conclusion is that I
should insert test on dimension when creating the geometry to prevent the
cretion of a 3rd dimension.</FONT></SPAN></P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">For exemple (in
TranslateGeometryElement())</FONT></SPAN> </P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">
...</FONT></SPAN> <BR><SPAN lang=fr-be><FONT
face="Times New Roman"> double dfX, dfY, dfZ =
0.0;</FONT></SPAN> </P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">
GetOrdinalPoint( nStartOrdinal, nDimension, &dfX, &dfY, &dfZ
);</FONT></SPAN> </P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">
poPoint->setX( dfX );</FONT></SPAN> <BR><SPAN lang=fr-be><FONT
face="Times New Roman"> poPoint->setY( dfY
);</FONT></SPAN> <BR><SPAN lang=fr-be><FONT
face="Times New Roman"> if ( nDimension>2 )
poPoint->setZ( dfZ ); </FONT></SPAN></P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">If you agree with this last
strategie, I would provide a patch with this kind of test for all geometries
created in TranslateGeometry() </FONT></SPAN></P>
<P><SPAN lang=fr-be><FONT face="Times New Roman"> Note:
The test "nDimension>2" seems beter than "nDimension=3" because if
SDO_GEOMETRY is 4 (permitted), we will generate a 3D OGRGeometry insteed of
a 2D. </FONT></SPAN></P>
<P><SPAN lang=fr-be><FONT face="Times New Roman"> Best
regards,</FONT></SPAN> </P>
<P><SPAN lang=fr-be><FONT face="Times New Roman">
Nicolas</FONT></SPAN> </P>
<P><SPAN lang=fr-be><FONT face="Courier New"
size=2>==================================================</FONT><BR><FONT
face="Courier New" size=2>Nicolas Simon, Informaticien</FONT>
</SPAN><BR><SPAN lang=fr><FONT face="Courier New" size=2>Service Public de
Wallonie (SPW)</FONT></SPAN> <BR><SPAN lang=fr><FONT face="Courier New"
size=2>Direction générale opérationnelle Agriculture, Ressources Naturelles
et Environnement (DGARNE)</FONT></SPAN> <BR><SPAN lang=fr><FONT
face="Courier New" size=2>Département des Aides</FONT></SPAN> <BR><SPAN
lang=fr><FONT face="Courier New" size=2>Direction de l'Octroi des Aides
agricoles - Service Informatique</FONT></SPAN> <BR><SPAN lang=fr-be><FONT
face="Courier New" size=2>14, Chaussée de Louvain - 4e étage</FONT><FONT
face="Times New Roman"><BR></FONT><FONT face="Courier New" size=2>5000
Namur</FONT><FONT face="Times New Roman"><BR></FONT><FONT face="Courier New"
size=2>BELGIUM</FONT> </SPAN></P></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>