[gnome-maps] Use Place instead of Geocode.Place
- From: Damián Nohales <dnohales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] Use Place instead of Geocode.Place
- Date: Mon, 22 Dec 2014 17:59:01 +0000 (UTC)
commit e9b9d0027c90353b1078ea359ad46d0cc44be714
Author: Damián Nohales <damiannohales gmail com>
Date: Mon Dec 22 10:46:29 2014 -0300
Use Place instead of Geocode.Place
https://bugzilla.gnome.org/show_bug.cgi?id=741767
src/geoclue.js | 3 ++-
src/geocodeService.js | 10 +++++++++-
src/mapView.js | 3 ++-
src/overpass.js | 23 ++++++++++-------------
src/placeEntry.js | 3 ++-
src/searchResultBubble.js | 9 +++------
src/turnPointMarker.js | 5 +++--
7 files changed, 31 insertions(+), 25 deletions(-)
---
diff --git a/src/geoclue.js b/src/geoclue.js
index e224923..92e8033 100644
--- a/src/geoclue.js
+++ b/src/geoclue.js
@@ -26,6 +26,7 @@ const Gio = imports.gi.Gio;
const Lang = imports.lang;
const Application = imports.application;
+const Place = imports.place;
const Utils = imports.utils;
const _ = imports.gettext.gettext;
@@ -156,7 +157,7 @@ const Geoclue = new Lang.Class({
_updateLocation: function(location) {
if (!this.place)
- this.place = new Geocode.Place({ name: _("Current location") });
+ this.place = new Place.Place({ name: _("Current location") });
this.place.location = location;
this.emit('location-changed');
diff --git a/src/geocodeService.js b/src/geocodeService.js
index b39f0e2..83bd64e 100644
--- a/src/geocodeService.js
+++ b/src/geocodeService.js
@@ -25,6 +25,7 @@ const Geocode = imports.gi.GeocodeGlib;
const Lang = imports.lang;
const Application = imports.application;
+const Place = imports.place;
const Utils = imports.utils;
const GeocodeService = new Lang.Class({
@@ -49,6 +50,13 @@ const GeocodeService = new Lang.Class({
forward.search_async(cancellable, function(forward, res) {
try {
let places = forward.search_finish(res);
+
+ if (places !== null) {
+ places = places.map(function(p) {
+ return new Place.Place({ place: p });
+ });
+ }
+
callback(places);
} catch (e) {
callback(null);
@@ -63,7 +71,7 @@ const GeocodeService = new Lang.Class({
reverse.resolve_async(cancellable, (function(reverse, res) {
Application.application.unmark_busy();
try {
- let place = reverse.resolve_finish(res);
+ let place = new Place.Place({ place: reverse.resolve_finish(res) });
callback(place);
} catch (e) {
Utils.debug("Error finding place at " +
diff --git a/src/mapView.js b/src/mapView.js
index dd3e0a6..a5be3eb 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -29,6 +29,7 @@ const Lang = imports.lang;
const Application = imports.application;
const MapWalker = imports.mapWalker;
+const Place = imports.place;
const SearchResultMarker = imports.searchResultMarker;
const TurnPointMarker = imports.turnPointMarker;
const UserLocationMarker = imports.userLocationMarker;
@@ -210,7 +211,7 @@ const MapView = new Lang.Class({
route.path.forEach(this._routeLayer.add_node.bind(this._routeLayer));
let [lat, lon] = route.bbox.get_center();
- let place = new Geocode.Place({
+ let place = new Place.Place({
location : new Geocode.Location({ latitude : lat,
longitude : lon }),
bounding_box : new Geocode.BoundingBox({ top : route.bbox.top,
diff --git a/src/overpass.js b/src/overpass.js
index 752c075..39234f4 100644
--- a/src/overpass.js
+++ b/src/overpass.js
@@ -75,34 +75,31 @@ const Overpass = new Lang.Class({
}
try {
let jsonObj = JSON.parse(message.response_body.data);
+ this._populatePlace(place, jsonObj);
callback(true,
- message.status_code,
- this._createPlace(place, jsonObj));
+ message.status_code);
} catch(e) {
- callback(false, message.status_code, null);
+ callback(false, message.status_code);
}
}).bind(this));
},
- _createPlace: function(place, overpassData) {
+ _populatePlace: function(place, overpassData) {
let element = overpassData.elements[0];
- let newPlace = new Place.Place({ place: place });
if (!(element && element.tags && element.tags.name))
- return newPlace;
+ return;
if (element.tags.name)
- newPlace.name = element.tags.name;
+ place.name = element.tags.name;
if (element.tags.population)
- newPlace.population = element.tags.population;
+ place.population = element.tags.population;
if (element.tags.wikipedia)
- newPlace.wiki = element.tags.wikipedia;
+ place.wiki = element.tags.wikipedia;
if (element.tags.wheelchair)
- newPlace.wheelchair = element.tags.wheelchair;
+ place.wheelchair = element.tags.wheelchair;
if (element.tags.opening_hours)
- newPlace.openingHours = element.tags.opening_hours;
-
- return newPlace;
+ place.openingHours = element.tags.opening_hours;
},
_getQueryUrl: function(place) {
diff --git a/src/placeEntry.js b/src/placeEntry.js
index 78ae7d2..42e8d93 100644
--- a/src/placeEntry.js
+++ b/src/placeEntry.js
@@ -29,6 +29,7 @@ const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Application = imports.application;
+const Place = imports.place;
const PlaceStore = imports.placeStore;
const SearchPopup = imports.searchPopup;
const Utils = imports.utils;
@@ -208,7 +209,7 @@ const PlaceEntry = new Lang.Class({
let parsedLocation = this._parseCoordinates(this.text);
if (parsedLocation) {
- this.place = new Geocode.Place({ location: parsedLocation });
+ this.place = new Place.Place({ location: parsedLocation });
return true;
}
diff --git a/src/searchResultBubble.js b/src/searchResultBubble.js
index 092d8c6..1d4a07f 100644
--- a/src/searchResultBubble.js
+++ b/src/searchResultBubble.js
@@ -60,12 +60,9 @@ const SearchResultBubble = new Lang.Class({
this._populate(place);
} else {
let overpass = new Overpass.Overpass();
- overpass.addInfo(this.place, (function(status, code, place) {
- if (!status)
- place = new Place.Place({ place: this.place });
-
- this._populate(place);
- Application.placeStore.addPlace(place,
+ overpass.addInfo(this.place, (function(status, code) {
+ this._populate(this.place);
+ Application.placeStore.addPlace(this.place,
PlaceStore.PlaceType.RECENT);
}).bind(this));
}
diff --git a/src/turnPointMarker.js b/src/turnPointMarker.js
index e5e659c..19a841d 100644
--- a/src/turnPointMarker.js
+++ b/src/turnPointMarker.js
@@ -27,6 +27,7 @@ const Mainloop = imports.mainloop;
const Application = imports.application;
const MapMarker = imports.mapMarker;
+const Place = imports.place;
const TurnPointBubble = imports.turnPointBubble;
const Utils = imports.utils;
@@ -46,7 +47,7 @@ const TurnPointMarker = new Lang.Class({
this._turnPoint = params.turnPoint;
delete params.turnPoint;
- params.place = new Geocode.Place({
+ params.place = new Place.Place({
location: new Geocode.Location({
latitude: this._turnPoint.coordinate.get_latitude(),
longitude: this._turnPoint.coordinate.get_longitude()
@@ -110,7 +111,7 @@ const DestinationMarker = new Lang.Class({
_onMarkerDrag: function() {
let query = Application.routeService.query;
- let place = new Geocode.Place({
+ let place = new Place.Place({
location: new Geocode.Location({ latitude: this.latitude.toFixed(5),
longitude: this.longitude.toFixed(5) }) });
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]