11.异常 *** Starting uWSGI 2.0.12 (64bit) on [Tue Jun 1416:36:202016] *** compiled with version: 4.4.720120313 (Red Hat 4.4.7-16) on 02 January 201619:53:13 os: Linux-2.6.32-573.8.1.el6.x86_64 #1 SMP Tue Nov 1018:01:38 UTC 2015 nodename: vlnx160170.fsceshi.com machine: x86_64 clock source: unix pcre jit disabled detected number of CPU cores: 4 current working directory: /home/wans/FSPythonWSGIProcess writing pidfile to /tmp/FsPythonWSGIProcess.pid detected binary path: /usr/sbin/uwsgi your processes number limit is1024 your memory page size is4096 bytes detected max file descriptor number: 60000 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 4 your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is60 seconds mapped 1476277 bytes (1441 KB) for10 cores *** Operational MODE: preforking *** *** no app loaded. going in full dynamic mode ***
关闭nginx ,启动uwsgi后再启动nginx
优化点: 1.调整nginx worker_processes 4; worker_cpu_affinity 1000010000100001; 2.#cluster upstream backend{ server unix:///tmp/uwsgi.sock; server unix:///tmp/uwsgi1.sock; server unix:///tmp/uwsgi2.sock; server unix:///tmp/uwsgi3.sock; }
location / { include uwsgi_params; uwsgi_pass backend; } 问题总结: 1.yum安装遇到如下类似问题: yum install uwsgi Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.163.com No package uwsgi available. Error: Nothing to do 解决方案,添加epl至yum的源即可: yum install http://mirrors.isu.net.sa/pub/fedora/fedora-epel/7/x86_64/e/epel-release-7-6.noarch.rpm 参考文档:https://fedoraproject.org/wiki/EPEL/zh-cn
Lookup Type PostGIS Oracle MySQL [7] SpatiaLite
bbcontains X X X
bboverlaps X X X
contained X X X
contains X X X X
contains_properly X
coveredby X X
covers X X
crosses X X
disjoint X X X X
distance_gt X X X
distance_gte X X X
distance_lt X X X
distance_lte X X X
dwithin X X
equals X X X X
exact X X X X
intersects X X X X
overlaps X X X X
relate X X X
same_as X X X X
touches X X X X
within X X X X
left X
right X
overlaps_left X
overlaps_right X
overlaps_above X
overlaps_below X
strictly_above X
strictly_below X
####我这里只关注一下对mysql的空间操作支持
按我们的需要我们选用 within
bbcontains
支持:PostGIS,MySQL,SpatiaLite
查询数据库中空间数据的bbox包含在指定的空间bbox内的数据。
数据库 操作
PostGIS poly ~ geom
MySQL MBRContains(poly,geom)
SpatiaLite MbrContains(poly,geom)
bboverlaps
支持:PostGIS,MySQL,SpatiaLite
查询数据库中空间数据的bbox与指定的空间bbox相交的数据。
数据库 操作
PostGIS poly && geom
MySQL MBROverlops(poly,geom)
SpatiaLite MbrOverlops(poly,geom)
contained
支持:PostGIS,MySQL,SpatiaLite
查询数据库中空间数据的bbox完全包含指定的空间bbox的数据。
数据库 操作
PostGIS poly @ geom
MySQL MBRWithin(poly,geom)
SpatiaLite MbrWithin(poly,geom)
from django.contrib.gis.geos import (Polygon,Point)
point = Point(130,39)
buffer=point.buffer(degree)
进行within查询
AppPoint.objects.filter(point__within=buffer)
问题
这里给的半径通常是米为km,但是这个构建buffer的方法需要的参数是一个度。
degree=l*180/(math.pi*6371)
##测试方法和数据
def get_point(point,r): EARTH_R=6378.137 buffer = point.buffer(r*180/(math.pi*EARTH_R)) aps=AppPoint.objects.filter(point__within=buffer) for ap in aps: print ap.point.json,(math.pi*EARTH_R*ap.point.distance(point)/180)
其中点与点间的距离方法distance在django中解释为:
Returns the distance between the closest points on this Geometry and the other. Units will be in those of the coordinate system of the Geometry.
from django.contrib.gis.geos import (Polygon,Point) import math point = Point(130,39) EARTH_R=6378.137 buffer = point.buffer(r*180/(math.pi*EARTH_R)) aps=AppPoint.objects.filter(point__within=buffer)