Skip to content

Instantly share code, notes, and snippets.

View Komzpa's full-sized avatar

Darafei Praliaskouski Komzpa

View GitHub Profile
gis=> drop type if exists apple;
DROP TYPE
gis=> create type apple as (amount numeric(1,0));
CREATE TYPE
gis=> select '(1)'::apple;
apple
-------
(1)
(1 row)
given:
- Postgres database gis, user gis, accepting trust connections on localhost
# grab software
sudo apt install osmosis curl wget unzip
# import schema
curl https://raw.githubusercontent.com/openstreetmap/openstreetmap-website/master/db/structure.sql | psql
# get latest osmosis wit non-broken pbf support
wget http://bretth.dev.openstreetmap.org/osmosis-build/osmosis-latest.zip
unzip osmosis-latest.zip
drop table if exists building_travel_curve;
create table building_travel_curve as (
select
ST_MakeLine(ST_Centroid(p.way)
order by tsp.seq) as geom,
1 as id
from pgr_tsp(
$$
select
osm_id :: int4 as id,
@Komzpa
Komzpa / gevel_postgis.md
Last active May 7, 2021 00:35
Visualize PostGIS index using Gevel in Postgres 9.6

Visualize PostGIS index using Gevel in Postgres 9.6:

git clone git://sigaev.ru/gevel
cd gevel
git checkout bd8b8b031a8049a6e7c18c00946bfbd99d75d27f
USE_PGXS=1 make
sudo USE_PGXS=1 make install
psql -f /usr/share/postgresql/9.6/contrib/gevel.sql
drop function if exists progressbar( double precision, double precision, timestamptz );
create or replace function progressbar(
done_count float,
total_count float,
start_time timestamptz default now()
)
returns setof void
as $$
declare
display_progressbar boolean;
with params as (
select 'SRID=4326;POINT(0 0)' :: gemetry as geom
)
select
a.altitude,
a.distance,
b.altitude, -- may be null, then do not interpolate
b.distance -- may be null, then do not interpolate
from (-- closest linestring
select
/usr/bin/perl ../utils/create_undef.pl sfcgal.sql 96 > uninstall_sfcgal.sql
cat sfcgal_upgrade.sql.in postgis_drop_after.sql > sfcgal_upgrade.sql
cat postgis_drop_before.sql postgis_upgrade_for_extension.sql.in postgis_drop_after.sql > postgis_upgrade_for_extension.sql
echo "BEGIN;" > postgis_upgrade.sql
cat postgis_drop_before.sql postgis_upgrade.sql.in postgis_drop_after.sql >> postgis_upgrade.sql
echo "COMMIT;" >> postgis_upgrade.sql
gserialized_gist_nd.c: In function ‘gserialized_gist_compress’:
gserialized_gist_nd.c:148:11: error: array subscript is above array bounds [-Werror=array-bounds]
GIDX_SET_MAX(b,i,tmp);
root@debian:/home/kom/postgis# cat regress/jitbug.sql
set jit to on;
create extension postgis;
CREATE OR REPLACE FUNCTION utmzone(geometry)
RETURNS integer AS
$BODY$
DECLARE
geomgeog geometry;
zone int;
https://github.com/locationtech/jts/issues/298 broken delaunay triangulation:
1:
[66.103648384371410884341457858681679 68.588612471664760050771292299032211],[146.68071346210041383528732694685459 121.68071346210042804614204214885831],[128.86889656046744789819058496505022 117.26179755904141188693756703287363],[66.103648384371439306050888262689114 68.588612471664774261626007501035929],[169.55213966757199273160949815064669 146.13377653827689073295914568006992],[126.62939224605088384123519062995911 181.11140466039208263282489497214556],[74.434448280233709738240577280521393 78.630898779520691732614068314433098],[121.11140466039205421111546456813812 153.37060775394911615876480937004089],[98.888595339607888945465674623847008 186.62939224605085541952576022595167],[52.66066896814022157968793180771172 63.178539267712423566081270109862089],[85.321337936280443159375863615423441 86.357078535424832921307825017720461],[129.61570560806461571701220236718655 173.90180644032261625397950410842896],[91.52240934977427855301357340
chmod a+x ~
apt update
apt install build-essential autoconf automake libtool postgresql-server-dev-all libxml2-dev libgeos-dev libproj-dev libxml2-utils xsltproc bison postgresql-10
service postgresql start
su postgres -c 'createuser root'
su postgres -c 'psql -d postgres -c "alter user root superuser;"'
git clone git@github.com:postgis/postgis.git
cd postgis
./autogen.sh
./configure --without-raster