geoc_wgs84togcj02_point.sql 626 B

12345678910111213141516171819202122232425
  1. CREATE OR REPLACE FUNCTION "public"."geoc_wgs84togcj02_point"("geom" "public"."geometry")
  2. RETURNS "public"."geometry" AS $BODY$
  3. DECLARE
  4. lon numeric;
  5. lat numeric;
  6. d jsonb;
  7. dlon numeric;
  8. dlat numeric;
  9. BEGIN
  10. if st_geometrytype(geom) != 'ST_Point' then
  11. return geom;
  12. end if;
  13. lon := st_x(geom);
  14. lat := st_y(geom);
  15. if (geoc_is_in_china_bbox(lon, lat) = false) then
  16. return geom;
  17. end if;
  18. d := geoc_delta(lon, lat);
  19. dlon := d->0;
  20. dlat := d->1;
  21. return st_makepoint(lon + dlon,lat + dlat);
  22. END;
  23. $BODY$
  24. LANGUAGE plpgsql VOLATILE
  25. COST 100