The reason for the multiple results is that the STRtree queries based on
the envelopes of the indexed geometries. (This is known as a "primary
filter" in spatial querying [1]). You need to implement a "secondary
filter" to execute the actual spatial test you want to perform.
In the case of testing whether a point "belongs" to a line segment you will
need to decide whether you want a precise geometric test, or (more likely)
a test based on distance between the point and the linestring. For the
first case use Line.covers(Point), for the second use Line.distance(Point).
[1]
https://books.google.ca/books?id=8shsCQAAQBAJ&pg=PA405&lpg=PA405&dq=geometry+primary+filter&source=bl&ots=ziVSr9mspm&sig=dr55bdT8yt9nYyqI5ePW4HykJqY&hl=en&sa=X&ved=0ahUKEwjQmZqP2rjJAhUVfYgKHZEPAuMQ6AEINDAF#v=onepage&q=geometry%20primary%20filter&f=false
On Sun, Nov 29, 2015 at 6:14 AM, Saurav Ranjit <[email protected]>
wrote:
> Hi everyone,
>
> I am new to the jts. I am trying to query in which line segment the gps
> point belongs to using the STRtree. I created the STRtree using the WKT
> format of linestring. I am able to perform the query using "List<Object[]>
> search_result = index.query(search);". But in many case the it produced
> multiple result.
>
> For example for the point "13.7127, 100.52007", the query is giving me 3
> result of different line segments.
>
> LINESTRING (100.51997 13.71225,100.52005 13.71278,100.52009 13.71366)
> LINESTRING (100.52007 13.71224,100.52012 13.71263,100.52019
> 13.71351,100.52021 13.71375)
> LINESTRING (100.5196 13.71037,100.51978 13.71085,100.52001
> 13.71153,100.52017 13.71211,100.52021 13.71233,100.52026 13.71263,100.52033
> 13.71335,100.52035 13.71374,100.52035 13.71377,100.52033 13.7145,100.52023
> 13.7155,100.52023 13.71558,100.52023 13.7156,100.52023 13.71596)
>
> I would like to know exactly in which line segment the point belongs to. I
> have also attached the image of the point and the line segment here.
>
> Please let me know regarding my questions.
>
> Thank you very much for the help
>
> Regards,
> Saurav Ranjit
> Master's in Engineering of Remote Sensing and Geographic Information
> Systems (RSGIS)
> School of Engineering and Technology (SET)
> Asian Institute of Technology (AIT)
> Thailand
> Mobile: (+66) 800544946
> Skype: sauravranjit
>
>
> ------------------------------------------------------------------------------
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple
> OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
> _______________________________________________
> Jts-topo-suite-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
>
>
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Jts-topo-suite-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user