my problem is the following. I am writing a Matlab script, in which I want to perform the following steps:
- step1: Create a map (contour plot) on which seismic hazard (spectral displacement) as a function of region (Italy) is shown.
- step2: Extract the coordinates (getcountourlines) and the corresponding hazard values.
- step3: transform the extracted coordinates of the individual contour lines into SQL spatial data.
I successfully proceeded step 1 and 2, and now I am struggeling with step 3. Let's have a look at a simple but fictitious example:
contourline1 = [x1 y1 x2 y2 x3 y3 x1 y1];
contourline2 = [x4 y4 x5 y5 x6 y6 x4 y4];
with x1,...x6 and y1,...y6 as real numbers (coordinates). Hereby, contourline1 is the outline and contourline2 is the "hole" (or in different words: contourline2 is a real subset of contourline1). What is now my Goal?
GOAL: I would like that Matlab takes contourline1 and contourline2 and transforms it into SQL spatial data. Matlab's output should be a string, such that I simply can copy/paste it into SQL. The output string (SQL readable) should be of the following form:
POLYGON((x1 y1, x2 y2, x3 y3, x1 y1),(x4 y4, x5 y5, x6 y6, x4 y4))
In my script, I already combined "outline" and "hole":
outline_hole = [x1 y1 x2 y2 x3 y3 x1 y1 x4 y4 x5 y5 x6 y6 x4 y4];
That means that Matlab has to "complement" the vector above (outline_hole) with "(", ")" and ",". Does someone have an idea how to do that efficiently?
Thank you in advance for your help.
SpaceCowboy