Can geopy return geocoding quality? (using Bing API) - bing

I've been reading the docs for the Bing geocoder using geopy and there doesn't seem to be a parameter for geocoding quality as an output.
In particular, I'm looking for 'matchCodes' and 'confidence' as outlined here.
Anyone know if this is possible?
Thanks in advance.

Location.raw attribute contains the raw geocoding response, from which these params can be retrieved:
In [1]: import os
...: from geopy.geocoders import Bing
In [2]: g = Bing(api_key=os.environ['BING_KEY'])
...: l = g.geocode("moscow")
In [3]: l.raw
Out[3]:
{'__type': 'Location:http://schemas.microsoft.com/search/local/ws/rest/v1',
'bbox': [55.493934631347656,
37.31906509399414,
55.9488410949707,
37.94414520263672],
'name': 'Moscow City',
'point': {'type': 'Point',
'coordinates': [55.55002975463867, 37.36982727050781]},
'address': {'adminDistrict': 'Moscow City',
'countryRegion': 'Russia',
'formattedAddress': 'Moscow City'},
'confidence': 'High',
'entityType': 'AdminDivision1',
'geocodePoints': [{'type': 'Point',
'coordinates': [55.55002975463867, 37.36982727050781],
'calculationMethod': 'Rooftop',
'usageTypes': ['Display']}],
'matchCodes': ['Ambiguous']}
In [4]: l.raw['confidence']
Out[4]: 'High'
In [5]: l.raw['matchCodes']
Out[5]: ['Ambiguous']

Related

Change state of mapbox map upon loading

I'm working on a web app with Mapbox and I want to change the state of a created polygon to be selected without clicking upon loading.
I appreciate any help!
draw.add({
'id': 'polygon',
'type': 'Feature',
'properties': {},
'geometry': {
'type': 'Polygon',
'coordinates': [coordinates],
}
});
Current state
Desired state
You can use this to enter direct selection mode:
draw.changeMode('direct_select', { featureId: myFeatureId })
See the API docs for more info. https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/API.md

Open Street Map using OSMN: how to get building height?

I am trying to find a way to extract building heights. Here is what I've tried so far:
place_name = "Uptown, Dallas, Texas"
buildings = ox.geometries_from_place(place_name, tags={'building':True})
print(buildings.columns)
outputs:
Index(['amenity', 'geometry', 'nodes', 'addr:housenumber', 'addr:street',
'building', 'building:levels', 'height', 'name', 'office', 'wikidata',
'wikipedia', 'parking', 'addr:city', 'addr:postcode', 'addr:state',
'layer', 'cuisine', 'access', 'addr:country', 'brand', 'brand:wikidata',
'brand:wikipedia', 'opening_hours', 'operator', 'operator:wikidata',
'operator:wikipedia', 'phone', 'ref:walmart', 'shop', 'website',
'wheelchair', 'beds', 'emergency', 'gnis:feature_id', 'healthcare',
'old_name', 'ele', 'gnis:county_name', 'gnis:import_uuid',
'gnis:reviewed', 'source', 'fee', 'smoking', 'roof:levels',
'roof:shape', 'addr:unit', 'tourism', 'short_name', 'contact:website',
'outdoor_seating', 'ways', 'type'],
dtype='object')
height parameters are NaN for most values. The closet parameter is building:levels but it is just number of stories in buildings.

How to compute a GeoJson geometry area in dart / flutter

I'm building a flutter mobile app and I need to compute an area of some GeoJson geometries.
Say we have a GeoJson-like object:
final geo = {
"type": "Polygon",
"coordinates": [[
[-122.085, 37.423],
[-122.083, 37.423],
[-122.083, 37.421],
[-122.085, 37.421],
[-122.085, 37.423]
]]
};
Assuming the projection is EPSG:4326, how do we get the actual area of the geometry using flutter or dart?
Tried to use dart-simple-features, but this is no longer maintained and requires SDK < 2.0.0.
Another option that came to my mind is to use some JavaScript library in combination with flutter_webview_plugin, but oh my... That seems like an overkill!
Also there is a possibility to use platform-specific code, but for the sake of development experience: let's avoid testing on multiple platforms if possible...
Any ideas? Or recommendations?
Okay, no reply for almost a week... Created my first dart package:
https://pub.dev/packages/area
Simple to use:
import 'package:area/area.dart';
main() {
const world = {
'type': 'Polygon',
'coordinates': [
[
[-180, -90],
[-180, 90],
[180, 90],
[180, -90],
[-180, -90]
]
]
};
print("The world area is: ${area(world)} m²");
}
Feel free to use, hate or love ;)
You can use geojson_vi:
const world = {
'type': 'Polygon',
'coordinates': [
[
[-180, -90],
[-180, 90],
[180, 90],
[180, -90],
[-180, -90]
]
]
};
final geoJSONPolygon = GeoJSONPolygon.fromMap(world);
print(geoJSONPolygon.area);

Mongo DB Collection - Count values of an attribute

I have a mongo db with companies with the following data structure:
{'Beschreibung': [],
'Branche': ['Doctor'],
'Homepage': 'http://www.doctorsdomain.de',
'Mail': None,
'Name': ['Companyname'],
'Ort': 'Doctors City',
'PLZ': '12345 ',
'StrHausnummer': 'Doctors Street',
'Telefonnummer': '1235345646',
'_id': ObjectId('sadfsdfawdfawedfbad5f'),
'domain': 'doctorsdomain',
'doctors': [{'Salutation': 'Dear Madame', 'Name': 'Maximiliane Mustermann'},
{'Salutation': 'Dear Mister', 'Name': 'Bernd Beispiel'}],
'other information'
I don't find the query to count how many names (doctors) I have in my database.
I tried something like
collection.find({"doctors":{"$exists":1}}).count()
but than I only get the number of the companies where doctors exists.
Need help please!
Thanks a lot!

Websocket does not work in Ionic

What should I do in order to use websocket in my ionic app?
I couldn't find any info in docs about this.
I'm just writing in my code:
.controller('Controller', function($scope) {
$scope.planets = [{'name': 'Меркурий', 'order': '1'},
{'name': 'Венера', 'order': '2'},
{'name': 'Земля', 'order': '3'},
{'name': 'Марс', 'order': '4'},
{'name': 'Юпитер', 'order': '5'},
{'name': 'Сатурн', 'order': '6'},
{'name': 'Уран', 'order': '7'},
{'name': 'Нептун', 'order': '8'},
{'name': 'Плутон', 'order': '9'},
];
$scope.sendData = function(selected) {
var planets = $scope.planets;
var num;
for (var i=0; i < planets.length; i++) {
if (planets[i].name === selected) {
num = planets[i].order;
}
}
var socket = new WebSocket("ws://somesource.com");
socket.send(num);
socket.onmessage = function(data) {
alert(data);
};
};
})
And nothing...
By design somesource.com must return me some data responding on my "num".
It's likely you would have found something if you had searched for WebSockets on Cordova instead of Ionic (Cordova is an underlying component of Ionic).
WebSockets are not officially supported because Android has no native WebSocket support and only the newest iOS devices have native WebSocket support:
WebSockets or an alternative with phonegap?
https://www.quora.com/Does-PhoneGap-support-WebSocket
As an alternative, I recommend following this tutorial to learn how to use Socket.IO with Ionic:
https://www.sitepoint.com/using-socket-io-and-cordova-to-create-a-real-time-chat-app/