Subscribe to this thread
Home - General / All posts - In quest for an additional function (?) for adjacent areas
yves61
403 post(s)
#07-Mar-23 21:16

I am struggling to fetch adjacent areas (using either GeomAdjacent or GeomOverlayAdjacent ) from 2 separate drawing layers, where areas are adjacent in that - different from M9's "adjacent" definition - they are :

not containing, not contained in, not intersecting, and sharing more than just one (point) location.

In the attached simplified example map the query will return 4 records, but my aim is to have the query return only that record with the green area from Drw_2 ( not by just filtering on the area's mfd_id value).

Any guidance on elaborating the query in order to return only that record with the green area from Drw_2 is much appreciated.

Added : or how to delete those records returned by the query where the areas from the 2 separate drawings merely touch in one point

Attachments:
adjacent_areas.mxb

oeaulong

503 post(s)
#07-Mar-23 23:28

It seems like you would need to take each touching Geoms from [Drw_2] and nest a subquery of those to find how many coordinates are touching (>1 to be selected and returned).

yves61
403 post(s)
#08-Mar-23 07:54

Thank you for your comment, on the other hand I have no clue how to do this .

yves61
403 post(s)
#08-Mar-23 08:48

I also tried converting the areas to lines (via Transform) and/or to boundaries (via geomBounds), but no success in achieving my aim.

Has M9 got a function ( or combination of functions) to return only adjacent areas that so to speak "share whole or a part of their adjacent boundary lines" ( without the 'M9 adjacent' areas that share only one or several point locations) .

adamw


10,439 post(s)
#09-Mar-23 09:10

There is no such function built-in, but you can try to construct one. Eg:

--SQL9

 

FUNCTION GeomAdjacentBoundary(@g1 GEOM, @g2 GEOM, @e FLOAT64BOOLEAN AS

  GeomAdjacent(@g1, @g2, @e) AND

  GeomCoordCount(GeomIntersectLines(

    GeomConvertToLine(@g1), GeomConvertToLine(@g2), @e

  )) > 1

END;

 

SELECT 

  d1.[mfd_id],

  d1.[adj_mfd_id]

  d1.[Geom],

  d2.[geom] as d2_Geom,

  d2.[mfd_id] as d2_mfd_id

FROM [Drw_1 TABLE] AS d1 LEFT JOIN (

  SELECT

    [mfd_id],

    [geom]

  FROM [Drw_2 TABLE] 

AS d2 ON GeomAdjacentBoundary(d1.[Geom], d2.[geom], 0); 

This will fail when two areas touch in, say, two point locations, not along a line. But for simple cases, this will be enough.

yves61
403 post(s)
#09-Mar-23 10:52

Thank you Adam for this Function and Query example.

I found in the mean time , for my needs, this solution working too :

- split Drw_1 to segments --> Drw_1_segments

- using GeomContains (Drw_2.[Geom], Drw_1_segments.[geom], 0)

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.