[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] Check identical point
From:       Nicklas_Avén <nicklas.aven () jordogskog ! no>
Date:       2010-05-22 13:46:04
Message-ID: 201005221346.o4MDk47c031975 () mail-core ! space2u ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Oh, I saw my own typo (forget the arguments for pointdistance3d). the query should be

Select * from table1, table2 
where table1.the_geom &amp;&amp;ST_Expand(table2.the_geom, 0.1) and
 table2.the_geom &amp;&amp; ST_Expand(table1.the_geom, 0.1) and 
pointdistance3d(table1.the_geom, table2.the_geom)&lt;=0.1;

/Nicklas

2010-05-22 Nicklas Av&eacute;n  wrote:

Hallo
> 
> The ST_DWithin fuction will only check the 2d distance and not care it the points \
> are far from each other in z direction. 
> If you need to also check they are close in z-direction I guess the easiest way is \
> to calculate the 3d distance between the points with Pythagorean theorem. The \
> cleanest maybe is to make a function of it like this: 
> 
> create or replace function pointdistance3d(p1 geometry, p2 geometry)
> returns double precision as
> $$
> select sqrt((st_x($1)-st_x($2))^2 + (st_y($1)-st_y($2))^2 + (st_z($1)-st_z($2))^2);
> $$
> language 'sql';
> 
> 
> then to get some speed of it you can use st_dwithin to do a first index-based \
> search. That is as said only a 2d calculation, but if the distance is more than \
> your tolerance in 2d it will be also in 3d. 
> I think the most effective way of doing this is to only do the bounding box \
> comparison that is built into st_dwithin and then go straightly to the 3d \
> calculation. That would look something like this if we use the tolerance 0.1 meters \
> (requires based coordinate sytem): 
> Select * from table1, table2 where table1.the_geom &amp;&amp; \
> ST_Expand(table2.the_geom, 0.1) and table2.the_geom &amp;&amp; \
> ST_Expand(table1.the_geom, 0.1) and pointdistance3d&lt;=0.1; 
> Hope that helps
> 
> Nicklas
> 
> 
> Try:
> > ST_DWithin(point1, point2, 0.00001) 
> > 
> > -F
> > 
> > > > 
2010/5/22 eehab hamzeh &lt;eehab40@hotmail.com>
> > > > 
Hello 
> > 
> > I want to check if two points are identical, the points has x,y,z coordinates and \
> > they are not exactly the same, i need to check the intersection between them with \
> > tolerance value. any direction of how to do that. 
> > Thank 
> > 
> > kind regards
> > > > 

> > 
> > 
> > 
> > 
> > Hotmail: Powerful Free email with security by Microsoft. Get it now.
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users@postgis.refractions.net
> > postgis.refractions.net/mailman/listinfo/postgis-users
> > 
> > 
> > 


[Attachment #5 (unknown)]

<html>
<head>
</head>
<body>Oh, I saw my own typo (forget the arguments for pointdistance3d). the query \
should be<br />  <br />
	Select * from table1, table2 <br />
	where table1.the_geom &amp;&amp; 
ST_Expand(table2.the_geom, 0.1) and<br />
	&nbsp;table2.the_geom &amp;&amp; ST_Expand(table1.the_geom, 0.1) and <br />
	
pointdistance3d(table1.the_geom, table2.the_geom)&lt;=0.1;<br />
	<br />
	/Nicklas<br />
	<br />
	 2010-05-22 Nicklas Av&eacute;n  wrote:<br />
	<br />
	Hallo<br />
	><br />
	>
	The ST_DWithin fuction will only check the 2d distance and not care it the points \
are far from each other in z direction.<br />  ><br />
	>
	If you need to also check they are close in z-direction I guess the easiest way is \
to calculate the 3d distance between the points with Pythagorean theorem. The \
cleanest maybe is to make a function of it like this:<br />  ><br />
	><br />
	>
	create or replace function pointdistance3d(p1 geometry, p2 geometry)<br />
	>
	returns double precision as<br />
	>
	$$<br />
	>
	select sqrt((st_x($1)-st_x($2))^2 + (st_y($1)-st_y($2))^2 + \
(st_z($1)-st_z($2))^2);<br />  >
	$$<br />
	>
	language 'sql';<br />
	><br />
	><br />
	>
	then to get some speed of it you can use st_dwithin to do a first index-based \
search. That is as said only a 2d calculation, but if the distance is more than your \
tolerance in 2d it will be also in 3d.<br />  ><br />
	>
	I think the most effective way of doing this is to only do the bounding box \
comparison that is built into st_dwithin and then go straightly to the 3d \
calculation. That would look something like this if we use the tolerance 0.1 meters \
(requires based coordinate sytem):<br />  ><br />
	>
	Select * from table1, table2 where table1.the_geom &amp;&amp; \
ST_Expand(table2.the_geom, 0.1) and<br />  >
	table2.the_geom &amp;&amp; ST_Expand(table1.the_geom, 0.1) and \
pointdistance3d&lt;=0.1;<br />  ><br />
	>
	Hope that helps<br />
	><br />
	>
	Nicklas<br />
	><br />
	><br />
	>
	Try:<br />
	>
	>&nbsp;&nbsp; ST_DWithin(point1, point2, 0.00001) <br />
	>
	><br />
	>
	>-F<br />
	>
	><br />
	>
	>>
	>
	<div>2010/5/22 eehab hamzeh &lt;<a>eehab40@hotmail.com</a>><br />
		>
		>





> 
		>
		<div>
Hello <br />
			>
			><br />
			>
			>I want to check if two points are identical, the points has x,y,z coordinates and \
they are not exactly the same, i need to check the intersection between them with \
tolerance value. any direction of how to do that.<br />  >
			><br />
			>
			>Thank <br />
			>
			><br />
			>
			>kind regards<br />
			>
			>>
			>
			<div><br />
				>
				><br />
				>
				><br />
				>
				><br />
				>
				><br />
				>
				><hr />
				
				Hotmail: Powerful Free email with security by Microsoft. <a \
href="https://signup.live.com/signup.aspx?id=60969" target="_blank">Get it \
now.</a></div>

</div>
<br />
		>
		>_______________________________________________<br />
		>
		>
postgis-users mailing list<br />
		>
		><a>postgis-users@postgis.refractions.net</a><br />
		>
		><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">postgis.refractions.net/mailman/listinfo/postgis-users</a><br />  >
		><br />
		>
		></div><br />
	>
	>



</body>
</html>



_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic