Created
August 21, 2020 17:35
-
-
Save ParisaRashidi/463f369d50c5764025eca375e3fce79d to your computer and use it in GitHub Desktop.
postgis function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace function point_distributor(latitudePoint1 double precision , | |
latitudePoint2 double precision, | |
longitudePoint1 double precision, | |
longitudePoint2 double precision, | |
x integer,--the length | |
y integer -- the width | |
) RETURNS void | |
language plpgsql | |
as | |
$$ | |
DECLARE | |
grid_view_longitude double precision; | |
grid_view_latitude double precision; | |
BEGIN | |
FOR i in 0..x LOOP | |
FOR j in 0..y LOOP | |
grid_view_latitude = latitudePoint1+((latitudePoint2-latitudePoint1)/x)*(i+1/2); | |
grid_view_longitude = longitudePoint1 +((longitudePoint2-longitudePoint1)/y)*(j+1/2); | |
INSERT INTO tbl_grid(lat,long) | |
values (grid_view_latitude,grid_view_longitude); | |
END loop; | |
END LOOP ; | |
END; | |
$$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment