WITH values(location, userid) as (
VALUES (st_geomfromewkt('0101000000000000C04141464000000000FE174440'),5))
SELECT st_distance(p.location,(SELECT location FROM values where v.userid = "blacklisterId")::geometry)
FROM values as v,live.partners as p
Inner JOIN backend.cars c ON (c."userId" = p."partnerId" AND c.active = true)
Inner JOIN backend."carCompatibleTariffs" cCT ON c."carId" = cCT."carId" and 1 = cCT."tariffId" AND cCT.active = true
LEFT JOIN backend."userBlacklist" bl on 5 = bl."blacklisterId" AND p."partnerId" = bl."blacklistedId"
WHERE bl."blacklistedId" ISNULL
--AND st_dwithin(p.location::geography,(SELECT FROM values where v.userid = "blacklisterId")::geography,1500)
--ORDER BY st_distance(p.location,(SELECT location FROM values where v.userid = "blacklisterId")::geometry) ASC;
如何将文本值表作为几何或地理,我尝试使用ST_GeographyFromText,ST_GeogmetryFromText和st_makepoint((选择st_x),(选择st_y)),但它总是返回null,我该如何解决?< / p>
答案 0 :(得分:0)
您的问题可能在其他地方。您的几何图形似乎有效:
WITH values(location, userid) AS
(VALUES ('0101000000000000C04141464000000000FE174440',5),
('0101000000000000200A45464000000000D7174440',16))
SELECT ST_Distance(location::GEOMETRY,ST_GeomFromText('POINT(44 45)')) FROM values;
st_distance
------------------
4.83948955585514
4.84387473202619
(2 Zeilen)
这里有几个关于不同类型的几何文字的例子:
db=# SELECT ST_GeomFromText('POINT(1 2)');
st_geomfromtext
--------------------------------------------
0101000000000000000000F03F0000000000000040
(1 Zeile)
db=# SELECT ST_GeomFromGeoJSON('{"type":"Point","coordinates":[1,2]}');
st_geomfromgeojson
--------------------------------------------
0101000000000000000000F03F0000000000000040
(1 Zeile)
db=# SELECT ST_GeomFromEWKT('SRID=4269;POINT(1 2)');
st_geomfromewkt
----------------------------------------------------
0101000020AD100000000000000000F03F0000000000000040
(1 Zeile)
db=# SELECT ST_GeomFromGML('<gml:Point><gml:coordinates>1,2</gml:coordinates></gml:Point>');
st_geomfromgml
--------------------------------------------
0101000000000000000000F03F0000000000000040
(1 Zeile)
db=# SELECT ST_GeomFromKML('<Point><coordinates>1,2</coordinates></Point>');
st_geomfromkml
----------------------------------------------------
0101000020E6100000000000000000F03F0000000000000040
(1 Zeile)
答案 1 :(得分:0)
这个可以是你的意图:
$schedule->job(new CustomCommand)->everyFiveMinutes();