Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5996099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:03:16+00:00 2026-05-23T00:03:16+00:00

I’ve a SDO_GEOMETRY column containing quite large multi polygons , defined like this: INSERT

  • 0

I’ve a SDO_GEOMETRY column containing quite large multi polygons, defined like this:

INSERT INTO t1 (i, d, g)
VALUES (
  25,
  'Multipolygon - multi-touch',
  sdo_geometry (2007, null, null, sdo_elem_info_array (1,1003,1, 17,1003,1), 
  sdo_ordinate_array (50,95, 55,95, 53,96, 55,97, 53,98, 55,99, 50,99, 50,95, 55,100, 55,95, 60,95, 60,100, 55,100))
);

Instead of two polygons as in the example above, one column contains > 100 polygons.

I’d like to filter this column so it only will return a relevant subset (using a bbox?), something like:

  SELECT filter(Geometry, bbox) from Table Where Id = 1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:03:17+00:00Added an answer on May 23, 2026 at 12:03 am

    A first attempt at brute force solution might look something like this:

    CREATE OR REPLACE FUNCTION FILTER_MULTI_POLYGONS
    (
        udtGeometry IN SDO_GEOMETRY,
        udtMask IN SDO_GEOMETRY,
        dTolerance IN NUMBER
    )
    RETURN SDO_GEOMETRY
    AS
        iElements INTEGER;
        udtElement SDO_GEOMETRY;
        udtResult SDO_GEOMETRY := NULL;
        iCount INTEGER;
    BEGIN
        IF udtGeometry IS NOT NULL THEN
            iElements := SDO_UTIL.GETNUMELEM(udtGeometry);
            FOR iElement IN 1..iElements
            LOOP
                udtElement := SDO_UTIL.EXTRACT(udtGeometry, iElement);
                IF SDO_GEOM.SDO_DISTANCE(udtElement, udtMask, dTolerance) <= dTolerance THEN
                    IF udtResult IS NULL THEN
                        udtResult := udtElement;
                    ELSE
                        udtResult := SDO_UTIL.APPEND(udtResult, udtElement);
                    END IF;
                END IF;
            END LOOP;
        END IF;
        RETURN udtResult;
    END;
    

    I say brute force because:

    1. The individual sub-polygons are not indexed, so this solution does not leverage spatial indexing. If performance is important enough, it may be worthwhile to break your multi-polygons into their constitutent sub-polygons (with one row in your source table per sub-polygon) so that you can use a different solution that takes advantage of spatial indexing. You could do this either up front (by changing the design of your source table) or behind the scenes (maybe using a materialized view based on your original table).

    2. It looks like you are on Oracle XE, and so are limited to the Locator subset of the Oracle Spatial functionality.

    3. Items 1 and 2 mean that your only built-in choice for determining which sub-polygons interact with the mask appears to be via SDO_GEOM.SDO_DISTANCE. This is going to be resource intensive (since it will be called for every sub-polygon), and gives you only one type of interaction vs. the many that are possible with the built-in spatial operators (that rely on spatial indexing).

    4. SDO_UTIL.APPEND may not be the most performant (or correct, particularly if your multi-polygons are not disjoint) way of building up the “filtered” multi-polygon result, but it illustrates the concept.

    Anyway, this is what I get running your sample geometry against some sample masks. You should make sure the function returns the expected results against your real geometries.

    SQL> REM Example mask that overlaps first polygon only
    SQL> SELECT 
      2      FILTER_MULTI_POLYGONS
      3      (
      4          T1.G, 
      5          SDO_GEOMETRY
      6          (
      7              2003, 
      8              NULL, 
      9              NULL, 
     10              SDO_ELEM_INFO_ARRAY(1, 1003, 3),
     11              SDO_ORDINATE_ARRAY(0, 0, 53, 96)
     12          ),
     13          0.1
     14      ) AS RESULT
     15  FROM T1;
    
    RESULT(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    --------------------------------------------------------------------------------
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
    AY(50, 95, 55, 95, 53, 96, 55, 97, 53, 98, 55, 99, 50, 99, 50, 95))
    
    
    SQL> REM Example mask that overlaps second polygon only
    SQL> SELECT 
      2      FILTER_MULTI_POLYGONS
      3      (
      4          T1.G, 
      5          SDO_GEOMETRY
      6          (
      7              2003, 
      8              NULL, 
      9              NULL, 
     10              SDO_ELEM_INFO_ARRAY(1, 1003, 3),
     11              SDO_ORDINATE_ARRAY(56, 0, 60, 96)
     12          ),
     13          0.1
     14      ) AS RESULT
     15  FROM T1;
    
    RESULT(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    --------------------------------------------------------------------------------
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
    AY(55, 100, 55, 95, 60, 95, 60, 100, 55, 100))
    
    
    SQL> REM Example mask that overlaps both polygons
    SQL> SELECT 
      2      FILTER_MULTI_POLYGONS
      3      (
      4          T1.G, 
      5          SDO_GEOMETRY
      6          (
      7              2003, 
      8              NULL, 
      9              NULL, 
     10              SDO_ELEM_INFO_ARRAY(1, 1003, 3),
     11              SDO_ORDINATE_ARRAY(0, 0, 100, 100)
     12          ),
     13          0.1
     14      ) AS RESULT
     15  FROM T1;
    
    RESULT(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    --------------------------------------------------------------------------------
    SDO_GEOMETRY(2007, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 17, 1003, 1), SDO
    _ORDINATE_ARRAY(50, 95, 55, 95, 53, 96, 55, 97, 53, 98, 55, 99, 50, 99, 50, 95,
    55, 100, 55, 95, 60, 95, 60, 100, 55, 100))
    
    
    SQL> REM Example mask that overlaps neither polygon
    SQL> SELECT 
      2      FILTER_MULTI_POLYGONS
      3      (
      4          T1.G, 
      5          SDO_GEOMETRY
      6          (
      7              2003, 
      8              NULL, 
      9              NULL, 
     10              SDO_ELEM_INFO_ARRAY(1, 1003, 3),
     11              SDO_ORDINATE_ARRAY(0, 0, 10, 10)
     12          ),
     13          0.1
     14      ) AS RESULT
     15  FROM T1;
    
    RESULT(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    --------------------------------------------------------------------------------
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.