ASCII_MAP_FLAT_FLEX
SQLScript procedure I came up with. Comments and suggestions for improvements are welcome!create procedure "NATURAL_EARTH"."ASCII_MAP_FLAT_FLEX" (IN resolution INT, IN primeMeridian FLOAT DEFAULT 0.0, IN northUp INT DEFAULT 1)
LANGUAGE SQLSCRIPT AS
loopLon, loopLat, calcLon, calcLat FLOAT;
meridianShift INTEGER;
stringSurface, pointSurface STRING;
BEGIN
IF northUp <> 1 THEN northUp := -1; END IF;
if resolution > 1000 THEN resolution := 1000; END IF;
IF resolution < 20 THEN resolution := 20; END IF;
loopLat := 90;
WHILE loopLat>=-90 DO
loopLon := -180;
calcLat := loopLat * northUp;
stringSurface := '';
WHILE loopLon<=180 DO
calcLon := loopLon * northUp;
select new st_point('POINT ('||:calcLon||' '||:calcLat||')', 1000004326).ST_CoveredBy(SHAPE) into pointSurface FROM "NATURAL_EARTH"."NE_EARTH";
stringSurface := concat (stringSurface, pointSurface);
loopLon := loopLon+360/resolution;
END WHILE;
meridianShift := mod(primeMeridian*northUp +360, 360) * resolution/360;
stringSurface := concat (right(stringSurface, resolution-meridianShift), left(stringSurface, meridianShift+1));
INSERT INTO "NATURAL_EARTH"."DRAW_EARTH" VALUES (:calcLat, :stringSurface);
loopLat := loopLat-360/resolution;
END WHILE;
END;
primeMeridian
😞 TRUNCATE TABLE "NATURAL_EARTH"."DRAW_EARTH";
CALL "NATURAL_EARTH"."ASCII_MAP_FLAT_FLEX"(RESOLUTION => 180, primeMeridian => -75);
SELECT replace(replace("SSTRING", '0', ' '), '1', '*') as "ASCIIMAP" FROM "NATURAL_EARTH"."DRAW_EARTH";
northUp
. By default is it equal to 1
, meaning the north is on top. Any other value will produce a map with the South pole being up. So, let's have a look at the world from the perspective of my Australian colleagues. TRUNCATE TABLE "NATURAL_EARTH"."DRAW_EARTH";
CALL "NATURAL_EARTH"."ASCII_MAP_FLAT_FLEX"(RESOLUTION => 180, primeMeridian => 158, northUp => 0);
SELECT replace(replace("SSTRING", '0', ' '), '1', '*') as "ASCIIMAP" FROM "NATURAL_EARTH"."DRAW_EARTH";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
38 | |
19 | |
13 | |
13 | |
11 | |
10 | |
10 | |
10 | |
8 | |
8 |