23 Mart 2020 Pazartesi

PostGIS ST_MakePoint

Giriş
Açıklaması şöyle.
SRID 4326 is assumed if unspecified. 
GEOGRAPHY tipindeki sütünlara değer atamak içindir.

Örnek
Elimizde şöyle bir tablo olsun
CREATE TABLE foo (geog GEOGRAPHY);
Şöyle yaparız.
INSERT INTO foo (geog) VALUES (ST_MakePoint(12.234,23.22));
Örnek - ST_SetSRID İçinde Kullanımı
Şöyle yaparız.
INSERT INTO foo (geog) 
 VALUES (ST_SetSRID(ST_MakePoint(-122.079513,45.607703), 4326));
Açıklaması şöyle.
ST_SetSRID will set the coordinate reference system of your geometry. This will allow PostGIS commands to understand how your grid will relate to other geometries.

Using ST_SetSRID is not essential, as long as all other geometries you may query against are known to be on the same grid. However, if you query against another table that has a SRID set, even if it is known to be of the same grid, PostGIS will fail with a 'mixed geometries' error, which is only resolved when both tables have the same SRID value.