[postgis-users] Left of/Right of test

Andreas Neumann a.neumann at carto.net
Tue Jul 23 08:23:15 PDT 2013


Hi Denis,

But the line has a direction and then the answer is quite clear. It
would be less clear in a case like this:



*
 * * * * * *
            *
             *
                    X

Where the point (X) is beyond the line - but even then the last segment
could be extended and left and right could be determined.

Maybe I have to write my own function and iterate over each line
segment, which will make the query even slower than it already is ;-(

Thanks anyway,
Andreas

Am 23.07.2013 17:16, schrieb Denis Rouzaud:
> I was thinking of the case where you have something like his:
> 
> 
> **********************
> *                    *
> *                    *
> *         X          *
> *                    *
> *                    *
> *                    *
> * *
> *******     **********
> 
> This might be a particular case, but I don't know the answer (as a human
> ;) )
> 
> Or did I miss your point ?
> 
> Cheers,
> 
> Denis
> 
> 
> 
> 
> On 07/23/2013 05:03 PM, Andreas Neumann wrote:
>> Hi Denis,
>>
>> Thank you for your reply.
>>
>> Actually I really want to test a LINESTRING against POLYGON centroids
>> (determined with ST_PointOnSurface), not just a line against a point.
>>
>> Is this question not answerable? As a human I can determine it. I am
>> aware about the edge cases where a point is on the line, but in my case
>> this can't happen as the data comes from a correctly defined polygon
>> mosaic.
>>
>>  From the lines of a polygon mosaic (directed lines node to node, no
>> double lines) I want to label what is left and what is right of a
>> polygon border. My theme is usage zones and I should label what is left
>> and right of the polygon border.
>>
>> Andreas
>>
>> Am 23.07.2013 16:48, schrieb Denis Rouzaud:
>>> Oops, here is the complete code:
>>>
>>> pointGeom << ST_Intersection( ST_MakeLine(
>>>               ST_MakePoint(ST_XMin(lineGeom), ST_Y(pointGeom)),
>>>               ST_MakePoint(ST_XMax(lineGeom), ST_Y(pointGeom))
>>>                            ), lineGeom
>>>                                                                  )
>>>
>>>
>>>
>>> On 07/23/2013 04:31 PM, Denis Rouzaud wrote:
>>>> Hi Andreas,
>>>>
>>>> Do you mean you want to test to a segment?
>>>>
>>>> Because, I can't see a true answer for a line.
>>>>
>>>> If you want to do test to a segment, it should do the job to test if
>>>> the intersection with the horizontal line (dy=0) over your point and
>>>> your input line is on the left/right to your point.
>>>>
>>>> So, maybe test:
>>>>
>>>> pointGeom << ST_Intersection( ST_MakeLine(
>>>>              ST_MakePoint(ST_XMin(lineGeom), ST_Y(pointGeom)),
>>>>              ST_MakePoint(ST_XMax(lineGeom), ST_Y(pointGeom))
>>>>                                                                 )
>>>>
>>>> You have to handle the case where your segment is horizontal, but then
>>>> a simple test with ST_Xmin/max should be enough.
>>>>
>>>> Cheers,
>>>>
>>>> Denis
>>>>
>>>> On 07/23/2013 03:54 PM, Andreas Neumann wrote:
>>>>> Hi,
>>>>>
>>>>> I want to test a point if it is left-of or right-of a given
>>>>> LINESTRING.
>>>>> I found the << >> and &< &> but they do not behave like I expected.
>>>>>
>>>>> Perhaps it is because they only test on the bounding box level and not
>>>>> on the real geometry?
>>>>>
>>>>> Is there a left/right of test available on the geometry instead of the
>>>>> bounding box?
>>>>>
>>>>> Thank you,
>>>>> Andreas
>>>>> _______________________________________________
>>>>> postgis-users mailing list
>>>>> postgis-users at lists.osgeo.org
>>>>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
> 



More information about the postgis-users mailing list