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)
// Add a new favorite using the service $scope.addFavorite = function(favorite) { FavoritesService.add(favorite).then(function () { $scope.favorites = FavoritesService.getFavorites(); $scope.hideModalAddFavorite(); }); };
// Delete a favorite using the service and update scope var $scope.deleteFavorite = function (favorite) { $scope.favorites = FavoritesService.delete(favorite); };
// Create the login modal that we will use later $ionicModal.fromTemplateUrl('templates/modals/login.html', { scope: $scope, animation: 'slide-in-up' }).then(function(modal) { $scope.loginModal = modal; });
// Triggered in the login modal to close it $scope.closeLogin = function() { InstagramService.loginCancelled(); $scope.loginModal.hide(); };
//Cleanup the modal when we're done with it! $scope.$on('$destroy', function() { $scope.loginModal.remove(); });
// Disable side-menu drag so that it doesnt interfere with our tinder cards functionality $scope.$on('$ionicView.enter', function() { $ionicHistory.clearHistory(); $ionicSideMenuDelegate.canDragContent(false); });
$scope.cardTransitionedLeft = function(index) { console.log('cardTransitionedLeft called with index:' + index); if (!InstagramService.isLoggedIn()) { console.log('not sure if you liked it before or not since you are not logged in; doing nothing!'); return; }
var post = $scope.model.currentPosts[index]; if (post.user_has_liked) { // jshint ignore:line PostsService.dislikePost(post.id) .success(function() { console.log('you disliked it!'); }); } else { console.log('you didnt like it in the first place!'); } };
$scope.cardTransitionedRight = function(index) { console.log('cardTransitionedRight called with index:' + index); if (!InstagramService.isLoggedIn()) { console.log('not sure if you liked it before or not since you are not logged in; if you login, we will like it for you'); }
var post = $scope.model.currentPosts[index]; if (!post.user_has_liked) { // jshint ignore:line PostsService.likePost(post.id) .success(function () { console.log('you liked it!'); }); } else { console.log('you already liked it previously!'); } };
$scope.cardDestroyed = function(index) { console.log('cardDestroyed called with index:' + index); $scope.model.currentPosts.splice(index, 1); };
Your Ionic project is readto go ! Some quick tips:
* cd into your project: $ cd trendicity
* Setup this project to use Sass: ionic setup sass
* Develop inthe browser with live reload: ionic serve
* Add aplatform (ios or Android): ionic platformadd ios [android] Note: iOS development requires OS X currently See the Android Platform Guide for full Android installation instructions: https://cordova.apache.org/docs/en/edge/guide_platforms_android_index.md.html
* Build your app: ionic build <PLATFORM>
* Simulate your app: ionic emulate <PLATFORM>
* Run your app onadevice: ionicrun <PLATFORM>
* Package an app using Ionic package service: ionic package <MODE> <PLATFORM>
For more help use ionic --help or ionic docs
Visit the Ionic docs: http://ionicframework.com/docs
New! Add push notifications to your Ionic app with Ionic Push (alpha)! https://apps.ionic.io/signup +---------------------------------------------------------+ + New Ionic Updates for August 2015 + + The View App just landed. Preview your apps onanydevice + http://view.ionic.io + + Invite anyone to preview and test your app + ionic share EMAIL + + Generate splash screens and icons with ionic resource + http://ionicframework.com/blog/automating-icons-and-splash-screens/ + +---------------------------------------------------------+
$ ionic serve ****************************************************** Upgrade warning - for the CLI to run correctly, it is highly suggested to upgrade the following: Please update your Node runtime to version >=0.12.x ****************************************************** Running live reload server: http://192.168.1.7:35729 Watching : [ 'www/**/*', '!www/lib/**/*' ] Running dev server: http://192.168.1.7:8100 Ionic server commands, enter: restart or r to restart the client app from the root goto or g and a url to have the app navigate to the given url consolelogs or c to enable/disable console log output serverlogs or s to enable/disable server log output quit or q to shutdown the server and exit
*Running a scheduler that will move scheduled jobs into queues when the time comes
*RQ Scheduler comes with a script rqscheduler that runs a scheduler process that polls Redis once every minute and move scheduled jobs to the relevant queues when they need to be executed:
scheduler.schedule( scheduled_time=datetime.now(), # Timefor first execution, in UTC timezone func=func, # Functionto be queued args=[arg1, arg2], # Arguments passed intofunctionwhen executed kwargs={'foo': 'bar'}, # Keyword arguments passed intofunctionwhen executed interval=60, # Timebefore the functioniscalled again, in seconds repeat=10 # Repeat this number of times (None means repeat forever) )
##使用方法
###初始化:
In [1]: from analytics.etl import analytics_etl In [2]: analytics_etl.init()