Global Positioning System Reference
In-Depth Information
(query, bbox, max_results=1000, cost_function=None). Consequently, they
need an instance of the GeoModel object, as exemplifi ed in Fig. 21. In the
fi rst line, we import the geo.geomodel library to allow the creation of a
class that inherits the GeoModel class. In the fragment between second and
fourth lines, the Points of Interest (POIs) class is created; and in the fragment
between seventh and eighth lines, the Municipalities class is created.
Hence, to fi nd all restaurants in New York as requested in query Q1, we
must store New York's bounding box through the geotypes.Box Geomodel
method, as shown in the fi rst two lines of the algorithm illustrated in
Fig. 22.
Since GeoModel cannot store geometries of the type polygon, it is not
possible to process the exact New York's polygon. An alternative solution
is to apply the New York's bounding box even though restaurants that are
not located in New York City can come as a result of the query. Hence, false
positives may occur in the result set. It is important to highlight that there is
no processing bounding box. Internally, the method bounding_box_fetch()
compares if the latitude and longitude of a point is located between the
latitudes and longitudes of the bounding box explicitly informed.
Next, in the fourth and fi fth lines of Fig. 22, we obtain all restaurants
within New York through the bounding_box_fetch method of the POIS
object. The parameters of this method are the query, the delimiting bounding
box, the maximum number of results, and the cost of executing the method.
The bounding box of New York is passed as a parameter to the method after
being computed in the fi rst and second lines of the algorithm. The other
1
2
appcfg.py upload_data -application= <app_id> -kind= Permission --
filename=pois.csv <app-directory>
Fig. 20. Uploading csv data to BigTable.
1
2
3
4
5
6
7
8
9
from geo.geomodel import GeoModel
class POIS(GeoModel):
label = db.StringProperty()
type = db.StringProperty()
class Municipalities (GeoModel):
name = db.StringProperty()
Fig. 21. Creation of the entities derived from GeoModel.
1
2
3
4
5
new_york_bb = geotypes.Box(-74.2557, -40.4957, -73.6895,
-40.9176)
restaurants = POIS.bounding_box_fetch
(POIS.all.filter('type =','restaurants'), new_york_bb)
Fig. 22. Algorithm to answer query Q1 in BigTable.
Search WWH ::




Custom Search