Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Generate grid line coordinates

User_1871Jun 14 2022 — edited Jun 14 2022

Edited:
Oracle 18c:
Using an SQL query, I want to generate a list of coordinates that make up the line segments of a square grid graph:

<img src="https://objectstorage.us-phoenix-1.oraclecloud.com/p/BqK85Rn1zA5MP0vYiqbAdPgs7Z6OmMxw8SD3WCFVm5kY8uReidZ1KPIKkgJ1hCkG/n/axciphqpnohg/b/forums-legacy/o/uploads/60ONNU0L1KRF/image.png" alt="image.png">STARTPOINT_X STARTPOINT_Y ENDPOINT_X ENDPOINT_Y
------------ ------------ ---------- ----------
           0            0          1          0 --horizontal lines
           1            0          2          0
           2            0          3          0
           3            0          4          0
           4            0          5          0
           5            0          6          0

         ...

           0            0          0          1 --vertical lines
           0            1          0          2
           0            2          0          3
           0            3          0          4
           0            4          0          5
           0            5          0          6

         ...

[220 rows selected]

Details:
The lines would be split at each intersection. So, in the image above, there are 220 lines. Each line is composed of two vertices.
Ideally, I would have the option of specifying in the query what the overall grid dimensions would be. For example, specify this somewhere in the SQL: DIMENSIONS = 10 x 10 (or DIMENSIONS = 100 x 100, etc.).
To keep things simple, we can assume the grid's overall shape will always be a square (length = width).
I've supplied sample data in this db<>fiddle. I created that data using Excel.
Hint: The vertical grid lines start at row 111.
The reason I want to generate this data is:
I want sample line data to work with when testing Oracle Spatial queries. Sometimes I need a few hundred lines. Other times, I need thousands of lines.
Also, if the lines are in a grid, then it will be obvious if any lines are missing in my results (by looking at the data in mapping software and spotting gaps).
How can I generate those grid line coordinates using Oracle Spatial?

This post has been answered by John OToole (Dublin) on Jun 14 2022
Jump to Answer
Comments
Post Details
Added on Jun 14 2022
2 comments
165 views