annotate scripts/delete-tables.py @ 372:349eb1e09f45

Cleaned the methods/functions indicating if a point is in a polygon In general, shapely should be used, especially for lots of points: from shapely.geometry import Polygon, Point poly = Polygon(array([[0,0],[0,1],[1,1],[1,0]])) p = Point(0.5,0.5) poly.contains(p) -> returns True poly.contains(Point(-1,-1)) -> returns False You can convert a moving.Point to a shapely point: p = moving.Point(1,2) p.asShapely() returns the equivalent shapely point If you have several points to test, use moving.pointsInPolygon(points, polygon) where points are moving.Point and polygon is a shapely polygon.
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 16 Jul 2013 17:00:17 -0400
parents 14a2405f54f8
children eaf7765221d9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
235
584613399513 added script and functions to remove object tables
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1 #! /usr/bin/env python
584613399513 added script and functions to remove object tables
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2
344
14a2405f54f8 slight modification to safety analysis and generalized script to delete computed data (objects and interactions)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 334
diff changeset
3 import sys, argparse
235
584613399513 added script and functions to remove object tables
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
4
584613399513 added script and functions to remove object tables
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5 import utils
584613399513 added script and functions to remove object tables
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6 import storage
584613399513 added script and functions to remove object tables
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7
344
14a2405f54f8 slight modification to safety analysis and generalized script to delete computed data (objects and interactions)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 334
diff changeset
8 parser = argparse.ArgumentParser(description='The program deletes the tables in the database before saving new results (for objects, tables object_features and objects are dropped; for interactions, the tables interactions and indicators are dropped')
14a2405f54f8 slight modification to safety analysis and generalized script to delete computed data (objects and interactions)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 334
diff changeset
9 #parser.add_argument('configFilename', help = 'name of the configuration file')
14a2405f54f8 slight modification to safety analysis and generalized script to delete computed data (objects and interactions)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 334
diff changeset
10 parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Sqlite database', required = True)
14a2405f54f8 slight modification to safety analysis and generalized script to delete computed data (objects and interactions)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 334
diff changeset
11 parser.add_argument('-t', dest = 'dataType', help = 'type of the data to remove', required = True, choices = ['object','interaction'])
14a2405f54f8 slight modification to safety analysis and generalized script to delete computed data (objects and interactions)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 334
diff changeset
12 args = parser.parse_args()
235
584613399513 added script and functions to remove object tables
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
13
344
14a2405f54f8 slight modification to safety analysis and generalized script to delete computed data (objects and interactions)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 334
diff changeset
14 storage.removeFromSqlite(args.databaseFilename, args.dataType)