Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fernandocarletti/geospatial-benchmark
Benchmark for polygon search between Solr 4, Postgres 9.2.2 + PostGIS and MySQL 5
https://github.com/fernandocarletti/geospatial-benchmark
Last synced: about 21 hours ago
JSON representation
Benchmark for polygon search between Solr 4, Postgres 9.2.2 + PostGIS and MySQL 5
- Host: GitHub
- URL: https://github.com/fernandocarletti/geospatial-benchmark
- Owner: fernandocarletti
- Created: 2013-01-16T17:29:40.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-01-16T17:32:25.000Z (over 11 years ago)
- Last Synced: 2023-03-12T05:51:32.781Z (over 1 year ago)
- Language: PHP
- Size: 8.59 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Geospatial Benchmark
====================Files used to test geospatial search time between Solr 4, Postgres 9.2.2 + PostGIS and MySQL.
MySQL requires this function to work:
```SQL
DELIMITER //CREATE function `giswithin` (pt POINT, mp MULTIPOLYGON) returns INT(1) DETERMINISTIC
begin
DECLARE str, xy TEXT;
DECLARE x, y, p1x, p1y, p2x, p2y, m, xinters DECIMAL(16, 13) DEFAULT 0;
DECLARE counter INT DEFAULT 0;
DECLARE p, pb, pe INT DEFAULT 0;SELECT Mbrwithin(pt, mp) INTO p;
IF p != 1 OR Isnull(p) THEN
RETURN p;
end IF;SELECT X(pt), Y(pt), Astext(mp) INTO x, y, str;
SET str = REPLACE(str, 'POLYGON((', '');
SET str = REPLACE(str, '))', '');
SET str = concat(str, ',');
SET pb = 1;
SET pe = locate(',', str);
SET xy = substring(str, pb, pe - pb);
SET p = instr(xy, ' ');
SET p1x = substring(xy, 1, p - 1);
SET p1y = substring(xy, p + 1);
SET str = concat(str, xy, ',');WHILE pe > 0 do
SET xy = substring(str, pb, pe - pb);
SET p = instr(xy, ' ');
SET p2x = substring(xy, 1, p - 1);
SET p2y = substring(xy, p + 1);
IF p1y < p2y THEN
SET m = p1y;
ELSE
SET m = p2y;
end IF;
IF y > m THEN
IF p1y > p2y THEN
SET m = p1y;
ELSE
SET m = p2y;
end IF;
IF y <= m THEN
IF p1x > p2x THEN
SET m = p1x;
ELSE
SET m = p2x;
end IF;
IF x <= m THEN
IF p1y != p2y THEN
SET xinters = (y - p1y) * (p2x - p1x) / (p2y - p1y) + p1x;
end IF;
IF p1x = p2x
OR x <= xinters THEN
SET counter = counter + 1;
end IF;
end IF;
end IF;
end IF;
SET p1x = p2x;
SET p1y = p2y;
SET pb = pe + 1;
SET pe = locate(',', str, pb);
end WHILE;RETURN counter % 2;
end;DELIMITER ;
```