I am wanting to use a GEOMETRY point and radius value that I pull from a postgis table. It looks like this:
CREATE TABLE waypoint (
name VARCHAR(30),
location GEOMETRY(Point, 3857),
radius INTEGER,
);
-- Update SRID to WGS84 (World Geodetic System 1984) - Standard for most calcluations worldwide
SELECT UpdateGEometrySRID('waypoint', 'location', 3857);
INSERT INTO
waypoint (name, location, radius)
SELECT
'Waypoiint 1', 'SRID=3857; POINT(-27.0 153.0)', 50;
So once I get the location
and radius
values in my javascript I wish to use it to display a circle on a map.
WPcircle = L.circleMarker(location, radius).addTo(mymap)
but that gives an error because location is invalid format. It is type GEOMETRY not latlng.
I want to do the equivalent of ST_AsText(location)
in javascript. Can I?
Is there an easy (or any?) way to convert it in javascript?
I think it is a bad idea to try and handle the WKB or WKT formats on a geometry
in Javascript.
Use the ST_X
and ST_Y
functions to get the coordinates of a point in the SQL query.