<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16809" name=GENERATOR></META></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=093331101-15032009><FONT face=Arial
color=#0000ff size=2>Nick,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=093331101-15032009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=093331101-15032009><FONT face=Arial
color=#0000ff size=2>Some general tips when suggesting changes.
</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=093331101-15032009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=093331101-15032009><FONT face=Arial
color=#0000ff size=2>1) Add an entry to our bug tracker
system</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=093331101-15032009><FONT face=Arial
color=#0000ff size=2>2) If you are providing code -- attach it to the bug
tracker system, but we would prefer a patch instead of a full
file.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=093331101-15032009><FONT face=Arial
color=#0000ff size=2>For windows development, I usually use Tortoise SVN.
It makes it wicked easy to create a patch and to work against the latest PostGIS
subversion trunk and branch. Presumably this patch you have is against
trunk since for branch we only accept minor changes and bug fixes that do not
introduce new functionality.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=093331101-15032009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=093331101-15032009><FONT face=Arial
color=#0000ff size=2>Aside from that -- keep up the good work and welcome to the
club.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=093331101-15032009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=093331101-15032009><FONT face=Arial
color=#0000ff size=2>Thanks,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=093331101-15032009><FONT face=Arial
color=#0000ff size=2>Regina</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B>
postgis-devel-bounces@postgis.refractions.net
[mailto:postgis-devel-bounces@postgis.refractions.net] <B>On Behalf Of
</B>nicklas.aven@jordogskog.no<BR><B>Sent:</B> Thursday, March 12, 2009 11:12
AM<BR><B>To:</B> postgis-devel@postgis.refractions.net<BR><B>Subject:</B>
[postgis-devel] RE: 40% faster st_distance and returningmeasurepoints
:-)<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV>Hi again</DIV>
<DIV> </DIV>
<DIV>I found that my modification crashed st_dwithin, but this version I think
will work.</DIV>
<DIV> </DIV>
<DIV>/Nicklas</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Datum: 2009-03-11 13:46:35<BR>Från: nicklas.aven@jordogskog.no<BR>Till:
<BR>Ämne: 40% faster st_distance and returning measurepoints :-)<BR><BR></DIV>
<META content="MSHTML 6.00.6000.16809" name=GENERATOR></META>
<P>Hallo</P>
<P>I'm new to this list and have done my first steps in writing c-code. Thanks
to the very well-written and readable source-code I think I have succeded over
my expectations.</P>
<P>What I have done is rewriting quite great parts of measures.c. My goal was to
get the points out of st_distance from where the distance was calculated.
<BR>The result was that st_distance worked about 40% faster on my small
testmaterial. The points I wanted is also there, but I don't know the best way
to output them.</P>
<P>The idea I have followed is just to store the shortest distance and it's
points in a new structure I have called DISTLINE. <BR>Then I only do testing if
a diastance is closer then the "earlier shortest" in "distance2d_pt_pt" so there
is no testing in the looping of the other relateted functions. </P>
<P>I think the progress in speed should make it interesting for implementing but
someone experienced have to take a serious look at it. <BR>I also would be
greatful if I could get some help with the output of my points. they are
included in the structure DISTLINE like </P>
<P>typedef struct<BR>{<BR> double d; /*distance*/<BR> POINT2D
*p1; /*1st measure point*/<BR> POINT2D *p2; /*2nd measure
point*/<BR>} DISTLINE;</P>
<P>and they will be present when the process returns to
function:<BR>lwgeom_mindistance2d_recursive</P>
<P>I attach my measure.c, libwgeom.h a small dataset with som roads in Norway
and my resulting dll</P>
<P>The test I have done to compare speed is just <BR>select
a.vegnummer,b.vegnummer, st_distance(a.the_geom,b.the_geom) as avstand from
distancetest a,distancetest b;<BR>on the attached dataset.<BR>My result was:</P>
<P>original measure.c<BR>Total query runtime: 3999 ms.<BR>400 rows
retrieved.</P>
<P>The new measure.c<BR>Total query runtime: 2374 ms.<BR>400 rows retrieved.</P>
<DIV>This increase in speed could be quite important on big "nearest neighbour"
calculations.</DIV>
<DIV>I also mean som function like st_shortestline(geom1,geom2) would be nice
and now the points for that line is ready to use.</DIV>
<P>Have a nice day<BR>from a quite proud beginner</P>
<P>Nicklas Avén</P>
<P> </P></BODY></HTML>