Skip to content

Commit

Permalink
fix tests and overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelacruzb committed Dec 29, 2023
1 parent 992dfb9 commit 856e26c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 32 deletions.
12 changes: 4 additions & 8 deletions clouds/redshift/modules/sql/constructors/ST_BEZIERSPLINE.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,19 @@ $$ LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION @@RS_SCHEMA@@.ST_BEZIERSPLINE
(GEOMETRY)
-- (linestring)
RETURNS VARCHAR(MAX)
-- RETURNS GEOMETRY
RETURNS GEOMETRY
STABLE
AS $$
SELECT @@RS_SCHEMA@@.__BEZIERSPLINE(ST_ASGEOJSON($1)::VARCHAR(MAX), 10000, 0.85)
-- SELECT ST_GEOMFROMGEOJSON(@@RS_SCHEMA@@.__BEZIERSPLINE(ST_ASGEOJSON($1)::VARCHAR(MAX), 10000, 0.85))
SELECT ST_GEOMFROMGEOJSON(@@RS_SCHEMA@@.__BEZIERSPLINE(ST_ASGEOJSON($1)::VARCHAR(MAX), 10000, 0.85))
$$ LANGUAGE sql;

CREATE OR REPLACE FUNCTION @@RS_SCHEMA@@.ST_BEZIERSPLINE
(GEOMETRY, INT)
-- (linestring, resolution)
RETURNS VARCHAR(MAX)
-- RETURNS GEOMETRY
RETURNS GEOMETRY
STABLE
AS $$
SELECT @@RS_SCHEMA@@.__BEZIERSPLINE(ST_ASGEOJSON($1)::VARCHAR(MAX), $2, 0.85)
-- SELECT ST_GEOMFROMGEOJSON(@@RS_SCHEMA@@.__BEZIERSPLINE(ST_ASGEOJSON($1)::VARCHAR(MAX), $2, 0.85))
SELECT ST_GEOMFROMGEOJSON(@@RS_SCHEMA@@.__BEZIERSPLINE(ST_ASGEOJSON($1)::VARCHAR(MAX), $2, 0.85))
$$ LANGUAGE sql;

CREATE OR REPLACE FUNCTION @@RS_SCHEMA@@.ST_BEZIERSPLINE
Expand Down
18 changes: 6 additions & 12 deletions clouds/redshift/modules/sql/constructors/ST_MAKEELLIPSE.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,28 @@ $$ LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION @@RS_SCHEMA@@.ST_MAKEELLIPSE
(GEOMETRY, FLOAT8, FLOAT8)
-- (center, xSemiAxis, ySemiAxis)
RETURNS VARCHAR(MAX)
-- RETURNS GEOMETRY
RETURNS GEOMETRY
STABLE
AS $$
SELECT @@RS_SCHEMA@@.__MAKEELLIPSE(ST_ASGEOJSON($1)::VARCHAR(MAX), $2, $3, 0, 'kilometers', 64)
-- SELECT ST_GEOMFROMGEOJSON(@@RS_SCHEMA@@.__MAKEELLIPSE(ST_ASGEOJSON($1)::VARCHAR(MAX), $2, $3, 0, 'kilometers', 64))
SELECT ST_GEOMFROMGEOJSON(@@RS_SCHEMA@@.__MAKEELLIPSE(ST_ASGEOJSON($1)::VARCHAR(MAX), $2, $3, 0, 'kilometers', 64))
$$ LANGUAGE sql;

CREATE OR REPLACE FUNCTION @@RS_SCHEMA@@.ST_MAKEELLIPSE
(GEOMETRY, FLOAT8, FLOAT8, FLOAT8)
-- (center, xSemiAxis, ySemiAxis, angle)
RETURNS VARCHAR(MAX)
-- RETURNS GEOMETRY
RETURNS GEOMETRY
STABLE
AS $$
SELECT @@RS_SCHEMA@@.__MAKEELLIPSE(ST_ASGEOJSON($1)::VARCHAR(MAX), $2, $3, $4, 'kilometers', 64)
-- SELECT ST_GEOMFROMGEOJSON(@@RS_SCHEMA@@.__MAKEELLIPSE(ST_ASGEOJSON($1)::VARCHAR(MAX), $2, $3, $4, 'kilometers', 64))
SELECT ST_GEOMFROMGEOJSON(@@RS_SCHEMA@@.__MAKEELLIPSE(ST_ASGEOJSON($1)::VARCHAR(MAX), $2, $3, $4, 'kilometers', 64))
$$ LANGUAGE sql;

CREATE OR REPLACE FUNCTION @@RS_SCHEMA@@.ST_MAKEELLIPSE
(GEOMETRY, FLOAT8, FLOAT8, FLOAT8, VARCHAR(10))
-- (center, xSemiAxis, ySemiAxis, angle, units)
RETURNS VARCHAR(MAX)
-- RETURNS GEOMETRY
RETURNS GEOMETRY
STABLE
AS $$
SELECT @@RS_SCHEMA@@.__MAKEELLIPSE(ST_ASGEOJSON($1)::VARCHAR(MAX), $2, $3, $4, $5, 64)
-- SELECT ST_GEOMFROMGEOJSON(@@RS_SCHEMA@@.__MAKEELLIPSE(ST_ASGEOJSON($1)::VARCHAR(MAX), $2, $3, $4, $5, 64))
SELECT ST_GEOMFROMGEOJSON(@@RS_SCHEMA@@.__MAKEELLIPSE(ST_ASGEOJSON($1)::VARCHAR(MAX), $2, $3, $4, $5, 64))
$$ LANGUAGE sql;

CREATE OR REPLACE FUNCTION @@RS_SCHEMA@@.ST_MAKEELLIPSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{"type": "LineString", "coordinates": [[121.025390625, -22.917922936146], [122.40878796386718, -22.04579264902263], [125.672291015625, -20.38080178786268], [129.4858663330078, -19.350050352981373], [132.704296875, -20.01569558887107], [135.25804138183594, -21.751132890668433], [137.26212890625, -24.05282839437401], [138.7404580078125, -26.51113113177312], [139.065328125, -29.074453813709233], [138.68492871093753, -31.163421738140773]]}
{"type":"LineString","coordinates":[[121.025390625,-22.917922936146],[122.408787963867,-22.0457926490226],[125.672291015625,-20.3808017878627],[129.485866333008,-19.3500503529814],[132.704296875,-20.0156955888711],[135.258041381836,-21.7511328906684],[137.26212890625,-24.052828394374],[138.740458007812,-26.5111311317731],[139.065328125,-29.0744538137092],[138.684928710938,-31.1634217381408]]}
{"type": "LineString", "coordinates": [[-6.0, -0.5], [-3.664930555555555, 0.425925925925926], [-1.061111111111112, -0.240740740740741], [1.5, 0.0], [4.06111111111111, 0.240740740740741], [6.664930555555557, -0.425925925925926]]}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{"type": "Polygon", "coordinates": [[[-73.8552510279278, 40.69875990076168], [-73.88727305602106, 40.71386857048946], [-73.91829086593725, 40.71364680576012], [-73.9391348512039, 40.709634787504875], [-73.95412635366824, 40.70506682134275], [-73.96651925076043, 40.70017993435736], [-73.97829506044877, 40.69448398629664], [-73.99100359724105, 40.686922671018635], [-74.00599882433386, 40.675240797295416], [-74.02174378146566, 40.65498289773168], [-74.02048678071606, 40.626394109162135], [-73.98849608124772, 40.61127430054531], [-73.95750094517604, 40.6114966073818], [-73.93666467847032, 40.61551220163249], [-73.92167439274749, 40.620083780265865], [-73.9092795100774, 40.62497407601799], [-73.89749910603689, 40.63067343282612], [-73.88478237941126, 40.638238360505696], [-73.86977253117084, 40.64992381005887], [-73.85400385410401, 40.670182251386066], [-73.8552510279278, 40.69875990076168]]]}
{"type":"Polygon","coordinates":[[[-73.8552510279278,40.6987599007617],[-73.8872730560211,40.7138685704895],[-73.9182908659373,40.7136468057601],[-73.9391348512039,40.7096347875049],[-73.9541263536682,40.7050668213427],[-73.9665192507604,40.7001799343574],[-73.9782950604488,40.6944839862966],[-73.991003597241,40.6869226710186],[-74.0059988243339,40.6752407972954],[-74.0217437814657,40.6549828977317],[-74.0204867807161,40.6263941091621],[-73.9884960812477,40.6112743005453],[-73.957500945176,40.6114966073818],[-73.9366646784703,40.6155122016325],[-73.9216743927475,40.6200837802659],[-73.9092795100774,40.624974076018],[-73.8974991060369,40.6306734328261],[-73.8847823794113,40.6382383605057],[-73.8697725311708,40.6499238100589],[-73.854003854104,40.6701822513861],[-73.8552510279278,40.6987599007617]]]}
{"type": "Polygon", "coordinates": [[[14.025651945102595, 0.643139887474501], [13.966322350235714, 0.676989374696651], [13.949057469288164, 0.682243693130648], [13.937791218833695, 0.685262266671341], [13.920212025893079, 0.689343743449833], [13.851904834790275, 0.689692135030598], [13.91123481846546, 0.655842669421623], [13.928499733699255, 0.650588334787248], [13.939765988224167, 0.647569750282519], [13.95734515890399, 0.643488257312855], [14.025651945102595, 0.643139887474501]]]}
{"type": "Polygon", "coordinates": [[[53.926679820162576, -10.771199588624045], [53.97565947191276, -10.766527634873915], [54.014901920097486, -10.7408989284746], [54.03942438052616, -10.704804086251515], [54.05009893077397, -10.664428129854691], [54.04717127681056, -10.622218072052796], [54.02828566737185, -10.581418796142149], [53.99135946342335, -10.550695880491965], [53.942640575928976, -10.542261926784727], [53.897252008932924, -10.558730567354848], [53.8653117158799, -10.590720059776746], [53.847874755112, -10.629391395890822], [53.84385496291736, -10.670909005067212], [53.85433410007079, -10.713061260528669], [53.882284838651685, -10.750335109689678], [53.926679820162576, -10.771199588624045]]]}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def test_bezierspline_success():

results = run_query(
f"""
SELECT @@RS_SCHEMA@@.ST_BEZIERSPLINE(
ST_GEOMFROMTEXT('{lines[0].rstrip()}'), 100, 0.85),
@@RS_SCHEMA@@.ST_BEZIERSPLINE(
ST_GEOMFROMTEXT('{lines[1].rstrip()}'), 60, 0.85)
SELECT ST_ASGEOJSON(@@RS_SCHEMA@@.ST_BEZIERSPLINE(
ST_GEOMFROMTEXT('{lines[0].rstrip()}'), 100, 0.85)),
ST_ASGEOJSON(@@RS_SCHEMA@@.ST_BEZIERSPLINE(
ST_GEOMFROMTEXT('{lines[1].rstrip()}'), 60, 0.85))
"""
)

Expand Down
12 changes: 6 additions & 6 deletions clouds/redshift/modules/test/constructors/test_ST_MAKEELLIPSE.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
def test_makeellipse_success():
results = run_query(
"""
SELECT @@RS_SCHEMA@@.ST_MAKEELLIPSE(
ST_POINT(-73.9385,40.6643), 5, 3, -30, 'miles', 20),
@@RS_SCHEMA@@.ST_MAKEELLIPSE(
ST_POINT(13.9385,0.6643), 10, 2, 15, 'kilometers', 10),
@@RS_SCHEMA@@.ST_MAKEELLIPSE(
ST_POINT(53.9385,-10.6643), 8, 7, 100, 'miles', 15)
SELECT ST_ASGEOJSON(@@RS_SCHEMA@@.ST_MAKEELLIPSE(
ST_POINT(-73.9385,40.6643), 5, 3, -30, 'miles', 20)),
ST_ASGEOJSON(@@RS_SCHEMA@@.ST_MAKEELLIPSE(
ST_POINT(13.9385,0.6643), 10, 2, 15, 'kilometers', 10)),
ST_ASGEOJSON(@@RS_SCHEMA@@.ST_MAKEELLIPSE(
ST_POINT(53.9385,-10.6643), 8, 7, 100, 'miles', 15))
"""
)

Expand Down

0 comments on commit 856e26c

Please sign in to comment.