2

I am looking for a solution for querying a point whether it is located inside a 3D object or not. If the point is located on the surface of 3D, I could use ST_3DIntersects or ST_3DIntersection.

But, if the point does not touch the surface, but is located inside the exterior, how could I query it?

In short, I am looking for SDO_Inside equivalent in PostGIS for 3D object.

ST_Contains does not support 3D.

Here is an example on using ST_3DIntersects. I chose a point that are inside the region. Result is false.

SELECT ST_3DIntersects(checkpoint,region) As checkpointinregion FROM (SELECT ST_GeomFromText('POINT(2604000 1205000 1500)', 2056) As checkpoint, (SELECT ST_GeomFromText('POLYHEDRALSURFACE(((2600000 1200000 1000, 2600000 1200000 2000, 2600000 1300000 2000, 2600000 1300000 1000, 2600000 1200000 1000)), ((2600000 1200000 1000, 2600000 1300000 1000, 2700000 1300000 1000, 2700000 1200000 1000, 2600000 1200000 1000)), ((2600000 1200000 1000, 2700000 1200000 1000, 2700000 1200000 2000, 2600000 1200000 2000, 2600000 1200000 1000)), ((2700000 1300000 1000, 2700000 1300000 2000, 2700000 1200000 2000, 2700000 1200000 1000, 2700000 1300000 1000)), ((2600000 1300000 1000, 2600000 1300000 2000, 2700000 1300000 2000, 2700000 1300000 1000, 2600000 1300000 1000)), ((2600000 1200000 2000, 2700000 1200000 2000, 2700000 1300000 2000, 2600000 1300000 2000, 2600000 1200000 2000)))', 2056)) As region) as myobjects;

checkpointinregion

f (1 row)

2
  • Point intersects another feature even if it is totally inside that and thus ST_3DIntersects should work for you postgis.net/docs/ST_3DIntersects.html. Can you share a query with two WKT features that proves the opposite?
    – user30184
    Aug 22, 2014 at 10:19
  • Thank you for the WKT. Documentation in postgis.net/docs/ST_3DIntersects.html says that like the 2D version, Intersects means the same as Not distinct. Either it is a bug or then I understand wrong what 3DIntersects should do. But now you have so fine query that you will for sure get an answer either from here or from PostGIS users.
    – user30184
    Aug 22, 2014 at 10:49

2 Answers 2

1

The documentation is a bit wrong. It does work for polyhedral surfaces as well (but without sfcgal it treats those as surfaces not volumetric). I'll correct the documentation on that. user30184 regarding your question it says Not Disjoint (not not Distinct). Disjoint is the opposite of intersects so that is right.

Tsolmon, If you treat your surface as an area, then the point isn't on the surface so you are right ST_3DIntersects (without sfcgal enabled) can't help you.

Your 3D polyhderal does appear to be a volume since:

SELECT ST_Dimension(ST_GeomFromText('POLYHEDRALSURFACE(((2600000 1200000 1000, 2600000  
1200000 2000, 2600000 1300000 2000, 2600000 1300000 1000, 2600000 1200000 1000)),  ((2600000 1200000 1000, 2600000 1300000 1000, 2700000 1300000 1000, 2700000 1200000 1000, 2600000 1200000 1000)), ((2600000 1200000 1000, 2700000 1200000 1000, 2700000 1200000 2000, 2600000 1200000 2000, 2600000 1200000 1000)), ((2700000 1300000 1000, 2700000 1300000 2000, 2700000 1200000 2000, 2700000 1200000 1000, 2700000 1300000 1000)), ((2600000 1300000 1000, 2600000 1300000 2000, 2700000 1300000 2000, 2700000 1300000 1000, 2600000 1300000 1000)), ((2600000 1200000 2000, 2700000 1200000 2000, 2700000 1300000 2000, 2600000 1300000 2000, 2600000 1200000 2000)))', 2056) );

Returns 3 (it would return 2 if it were an open surface).

So I would expect if you have compiled with sfcgal support and have switched your backend to use sfcgal, the ST_3DIntersects of sfcgal would kick in and treat this as a volume.

Even doing this:

SET postgis.backend = sfcgal;

and running your test, I still get false.

Does oracle return true for this? I'm not absolutely sure that SFCGAL ST_3DIntersects and ST_3DIntersection handle volumes. I think they do since I recall doing a spot check on this. Your box is so thin though that I can't easily tell if this point should be treated as inside or not.

Anyway I've put in a bug ticket to clarify the behavior of ST_3DIntersects. http://trac.osgeo.org/postgis/ticket/2904

1
  • Not Disjoint was naturally what I meant. Unfortunately comments can't be edited and I do not want to delete the whole comment.
    – user30184
    Aug 23, 2014 at 11:38
0

This is working if you make the POLYHEDRALSURFACE solid. I used ST_MakeSolid on the POLYHEDRALSURFACE surface and the query is returning true now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.