SQL/POSTGIS 使用函数实现ST_Intersects
来源:互联网 发布:奥飞娱乐怎么样 知乎 编辑:程序博客网 时间:2024/04/28 10:54
create or replace function ST_LineIntersects(x1 float, y1 float, x2 float, y2 float, x3 float, y3 float, x4 float, y4 float) returns booleanas $$declare a1 float; a2 float; b1 float; b2 float; c1 float; c2 float;begin a1 = y2 - y1; b1 = x1 - x2; c1 = a1*x1 + b1*y1; a2 = y4 - y3; b2 = x3 - x4; c2 = a2*x3 + b2*y3; if (a1*x3 + b1*y3) = c1 and (a1*x4 + b1*y4) = c1 then begin if (min(x1,x2)<=min(x3,x4) and min(x3,x4)<=max(x1,x2)) or (min(x1,x2)>=min(x3,x4) and max(x3,x4)>=min(x1,x2)) then return true; else return false; end if; end; elsif ((a1*x3+b1*y3-c1)*(a1*x4+b1*y4-c1)<=0) and ((a2*x1+b2*y1-c2)*(a2*x2+b2*y2-c2)<=0) then return true; end if; return false;end;$$ language plpgsql;
算法思路,相交线段必然是一条线段的两点分在另一条线段的两侧,则另L1的两端点在L2的两侧,L2的两端点在L1的两侧,则相交成立。
0 0
- SQL/POSTGIS 使用函数实现ST_Intersects
- ST_Intersects
- postGis 函数
- hibernate 支持 postgis函数
- POSTGIS常用函数
- postgis 常用函数
- POSTGIS常用函数
- Postgis常用函数
- PostGIS常用函数整理
- postgis常用函数
- PostGIS中的常用函数
- Postgis常用函数
- PostGIS常用函数
- PostGIS中的常用函数
- PostgreSQL+PostGIS的使用
- PostgreSQL+PostGIS的使用
- postGIS简单使用
- PostgreSQL+PostGIS的使用
- fedora23 安装vsftpd
- Android项目中的各个模块框架设计
- python爬虫:案例一:360指数
- 游戏中的角色类
- Android蓝牙开发简介
- SQL/POSTGIS 使用函数实现ST_Intersects
- (水)POJ-3262 贪心,背包,比率问题
- C#流程控制2
- 71.JAVA编程思想——JAVA与CGI
- linux日期命令date/cal
- 72.JAVA编程思想——P O S T 的概念
- Launcher
- Java 网络编程
- AngularJS(2)——AngularJS数据双向绑定