I have been reading around the documentation and the examples but still cant figure out a way to use ARCore/Sceneform with geolocations. An example would be opening my camera and according to my geo location and other places' geolocation I would render them on the camera if my camera was on the same compass direction as the object.
Can someone point me in the right direction of where I should be looking at and any guidance and is there something I can use from ARCore/Sceneform that would help with that?
ARCore's Geospatial API
With ARCore 1.31 Geospatial API you can obtain geospatial data from Google Earth 3D and Street View images (from Google Maps), to enable your ARCore app for global-scale location-based AR experiences. This data model, taken from billions of images, is provided with Google VPS.
To enable Geospatial API use the following code:
fun configureSession(session: Session) {
session.configure(
session.config.apply {
geospatialMode = Config.GeospatialMode.ENABLED
}
)
}
Then check if an object's TrackingState is TRACKING:
val earth = session?.earth ?: return
if (earth.trackingState != TrackingState.TRACKING) { return }
Now, you're ready to determine a pose of a new anchor:
val altitude = earth.cameraGeospatialPose.altitudeMeters - 1
val qtrnX = 0f; val qtrnY = 0f; val qtrnZ = 0f; val qtrnW = 1f;
earthAnchor = earth.createAnchor(latLng.latitude,
latLng.longitude,
altitude, qtrnX, qtrnY, qtrnZ, qtrnW)
Geospatial supported areas
Before using the Geospatial API, make sure the area you are in is supported.
I think there's nothing Sceneform specific to help you but I have some ideas:
1. The coordinate system is in meters which should help you to make the needed calculations.
2. You could let the user hold the device upright (check it via sensors) and get use the Camera pose to align it with all sensors you want to use like Compass and Geolocation. Position everything relative to this position. You maybe also want to create an Anchor to that position on order to keep everything updated as ARCore's understanding of the world improves.
Related
I am trying to create a Bigquery UDF function that uses Googles Geocoding service.
It seems we can import external libraries with the option parameter but I feel that I cant use the Geocoding service here.
Following my function approach:
CREATE OR REPLACE FUNCTION
functions.returnGeoCode(address STRING)
RETURNS Array<String>
LANGUAGE js AS """
var geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
alert(latitude);
}
});
"""
which complains because it does not know google of course saying ReferenceError: google is not defined at UDF$1(STRING) line 2, columns 23-24 when I try to use the function.
My ultimate goal is to convert addresses that I have in a Bigquery dataset to lat/longs so I can then create a heatmap in a visualization tool.
Any tips for my approach or something totally different? I saw some suggestions to use some public Bigquery datasets (openstreetmaps suggestion) but I have addresses from Germany and it does not cover that well.
Also Bigquery does not support the conversion this way it seems.
Thank you in advance!
Since the feature you need is from Geocoding, what I could suggest is you can script out everything where you use BigQuery API (to execute queries) and Geocoding API (to perform Geocoding calculations) in a javascript I suppose. You can perform the calculation of Geocoder separately from the query, afterwards use the returned value from Geocoder on your query using BigQuery API.
You can include a self-contained external javascript library, but it would not work with Geocoder service - here the javascript library makes external HTTP calls, which is not allowed for javascript UDF.
I think the appropriate solution is Cloud DataFlow - you can include arbitrary code there, without security and performance restrictions of UDF, read data out of BigQuery table, and write the results back.
If you have a lot of data, and Geocoder service becomes expensive, I think OpenStreetMaps can help - try to resolve data using OSM tables, then resolve the remaining addresses using Geocoder service.
Before you start reading: I have looked at the GraphQL documentation, but my usecase is so specific and I only need the data once, and therefore I allow myself to ask the community for help on this one to save some time and frustration (not planning to learn GraphQL in the future)
Intro
I am a CS student developing an app for Flutter on the side, where I need information about the name and location of every bus stop in a specific county in Norway. Luckily, there's an open GraphQL API for this (API URL: https://api.entur.io/stop-places/v1/graphql). The thing is, I don't know how to query a GraphQL API, and I do not want to spend time learning it as I am only going to fetch the data once and be done with it.
Here's the IDE for the API: https://api.entur.io/stop-places/v1/ide
And this is the exact query I want to perform as I want to fetch bus stops located in the county of Trondheim:
{
stopPlace(stopPlaceType: onstreetBus, countyReference: "Trondheim") {
name {
value
}
... on StopPlace {
quays {
geometry {
coordinates
}
}
}
}
}
The problem with this query though, is that I don't get any data when passing "Trondheim" to the countyReference (without countyReference I get the data, but not for Trondheim). I've tried using the official municipal number for the county as well without any luck, and the documentation of the API is rather poor... Maybe this is something I'll have to contact the people responsible for the API to figure out, which shouldn't be a problem.
But now back to the real problem - how can I make this query using the GraphQL package for Dart? Here's the package I'm planning to use: (https://pub.dev/packages/graphql)
I want to create a bus stop object for each bus stop, and I want to put them all in a list. Here is my bus stop model:
class BusStop with ChangeNotifier {
final String id;
final String name;
final LatLng location;
BusStop({
this.id,
this.name,
this.location
});
}
When it comes to authentication, here's what the documentation says:
This API is open under NLOD licence, however, it is required that all consumers identify themselves by using the header ET-Client-Name. Entur will deploy strict rate-limiting policies on API-consumers who do not identify with a header and reserves the right to block unidentified consumers. The structure of ET-Client-Name should be: "company - application"
Header examples: "brakar - journeyplanner" "fosen_utvikling - departureboard" "norway_bussekspress - nwy-app"
Link to API documentation: https://developer.entur.org/pages-nsr-nsr
Would be great to know how I should go about this as well! I'm grateful for every answers to this, I know I am being lazy here as of learning GraphQL, but for my usecase I thought it would take less time and frustration by asking here!
Getting the query right
First of all you seem to have GraphQL quite figured out. There isn't really much more to it than what you are doing. What queries an API supports depends on the API. The problem you seem to have is more related to the specific API that you are using. I might have figured the right query out for you and if not I will quickly explain what I did and maybe you can improve the query yourself:
{
stopPlace(stopPlaceType: onstreetBus, municipalityReference: "KVE:TopographicPlace:5001") {
name {
value
}
... on StopPlace {
quays {
geometry {
coordinates
}
}
}
}
}
So to get to this I started finding out more about "Trondheim" bei using the topographicPlace query.
{
topographicPlace(query: "Trondheim") {
id
name {
value
}
topographicPlaceType
parentTopographicPlace {
id
name {
value
}
}
}
}
If you do that you will see that "Trondheim" is not a county according to the API: "topographicPlaceType": "municipality". I have no idea what municipality is but the is a different filter for this type on the query that you provided. Then putting "Trondheim" there didn't yield any results so I tried the ID of Trondheim. This now gives me a bunch of results.
About the GraphQL client that you are using:
This seems to be an "Apollo Client" clone in Dart. Apollo Client is a heavy piece of software that comes with a lot of awesome features when used in a frontend application. You probably just want to make a single GraphQL request from a backend. I would recommend using a simple HTTP client to send a POST request to the GraphQL API and a JSON body (don't forget content type header) with the following properties: query containing the query string from above and variables a JSON object mapping variable names to values (only needed if you decide to add variables to your query.
I'm trying to find API method for Steam CSGO, which I can use to retreive all:
weapon categories;
wear;
exterior;
phase;
grade.
Any advice would be appreciated.
to retrieve the "Phase" of a item you would need to retrieve paintindex and check what "phase" said paintindex is.
to get the wear value, exterior etc you can simply use the "globaloffensive" npm module and then call the "inspectItem" function with the inspect_url for the item you want to get data for.
csgo.inspectItem("URL",function(item) {
let paintindex = item.paintindex; // ITEMS paintindex, used to identify phase...
let wear = item.paintwear; // "FLOAT VALUE".
let quality = item.quality;
//...
});
If you need a database for the "paintindex" you could check metjm.net.
Regards
few month ago i write something to get the latitude or longitude from google API. latter i get the database from drupal for latitude or longitude to most of city in worlds.
but the problem is that the same city name can be found two or more times in a area. like Firozabad in India and bangladesh both. Agra in UP and agar in Rajasthan.
means the confusion in name by user if they found two city by same name they are confused.
i hear that HTML 5 support latitude or longitude of the visiter but i need latitude or longitude where they are born or city they want to use to fill a form.
how i can get the latitude or longtiude from API like google and some other.
the process is that:
user put the location in textbox for getting their latitude or longitude.
for right thing i want to show them all location [if same thing found more then one].
they can choose the right location and after click they can get the lati and langitude.
how i can do this using any API.
If I understood you correctly then here's a Javascript function that returns a list of actual locations based on the address (full or partial) that user has entered:
getLocationsByAddress = function(address, onComplete) {
var geocoder = null;
var locations = [];
var location = null;
geocoder = new GClientGeocoder();
geocoder.getLocations(address, function(response) {
if (!response || response.Status.code != 200) {
if (typeof (onComplete) != 'undefined') {
onComplete([]);
}
} else {
for (var i = 0; i < response.Placemark.length; i++) {
location = response.Placemark[i];
locations[locations.length] = {
address: location.address,
x: location.Point.coordinates[1],
y: location.Point.coordinates[0],
zoom: 14
}
}
if (typeof (onComplete) != 'undefined') {
onComplete(locations);
}
}
});
}
The code uses API version 2 but I think it should be fairly easy to make it work with V3 (please see this API reference for details).
UPDATE
As #Maxym stated the V2 API is considered as deprecated and therefore shouldn't be used any further.
Take a look at this jQuery plugin. It claims to work with both V2 and V3 so you may want to examine the source code in order to find out how they do an it with V3.
I am not sure that it is about HTML 5. You just need to create sort of hints, where user can select which exactly city she means (the way Google does on maps.google.com - you enter "Odessa" and see list of cities with such name). Google has geocoder API but probably it should be used with Google Map (just read license).
So the process is easy: user enters city, you send it to geocoder to get list of cities with such a name and their coordinates. THen you show that list, user selects one and you have its coordinates.
There is documentation how to use Geocoding API v3 in JavaScript, as well as examples. This one show how to get coordinates from address, take into account that they process results[0] only, but you need to iterate over results to get all cities.
I have a list of addresses from a Database for which I'd like to put markers on a Yahoo Map. The addMarker() method on YMap takes a YGeoPoint, which requires a latitude and longitude. However, Yahoo Maps must know how to convert from addresses because drawZoomAndCenter(LocationType,ZoomLevel) can take an address. I could convert by using drawZoomAndCenter() then getCenterLatLon() but is there a better way, which doesn't require a draw?
You can ask the map object to do the geoCoding, and catch the callback:
<script type="text/javascript">
var map = new YMap(document.getElementById('map'));
map.drawZoomAndCenter("Algeria", 17);
map.geoCodeAddress("Cambridge, UK");
YEvent.Capture(map, EventsList.onEndGeoCode, function(geoCode) {
if (geoCode.success)
map.addOverlay(new YMarker(geoCode.GeoPoint));
});
</script>
One thing to beware of -- in this example the drawAndZoom call will itself make a geoCoding request, so you'll get the callback from that too. You might want to filter that out, or set the map's centre based on a GeoPoint.
If you're working with U.S. addresses, you can use geocoder.us, which has APIs.
Also, Google Maps Hacks has a hack, "Hack 62. Find the Latitude and Longitude of a Street Address", for that.