Natalka asked if I can make a maple leaf with Oracle Spatial.
The most basic way to draw any polygon with Oracle Spatial is to”
- Plot the shape on a graph.
- Add the grid coordinates to a polygon SDO_GEOMETRY object. Remember to go in a counter-clockwise direction.
For a maple leaf, I searched duckduckgo.com for a bit and found a very detailed grid mapping of a maple leaf.
The points in that doc are ordered in a clockwise direction, so I reversed the order and added them to an SDO_ORDINATE_ARRAY which generates the following.
It’s a nice leaf but not quite Canadian enough.
I was unable to find a complete mapping of a leaf closer to the Canadian flag, so I found several examples that were all similar but incomplete, and did my best to guess at the missing data.
I started at the top point and worked my way counter-clockwise around the leaf points to the bottom left stem point.
Since I centered it on the 0 x axis I simply removed the negative from the x ordinates, reversed the order of the coordinates and added them to the SDO_ORDINATE_ARRAY. Notice the start and end points are the same to close the polygon.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
select MDSYS.SDO_GEOMETRY(2003, 4326, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1), MDSYS.SDO_ORDINATE_ARRAY(0,7, -1.2,4.4, -3,5, -2,1, -4,3, -4.3,1.5, -7,2.5, -5.5,0, -7,-1, -3.3,-3.4, -4,-5, -.2,-4.2, -.2,-8, .2,-8, .2,-4.2, 4,-5, 3.3,-3.4, 7,-1, 5.5,0, 7,2.5, 4.3,1.5, 4,3, 2,1, 3,5, 1.2,4.4, 0,7)) MapleLeaf from dual; |
After checking that the object is valid using .st_isvalid() I generated this leaf.