Getting Feature and Geometry error in Google Earth Engine - google-earth-engine

This is the code:
//print('Amsterdam', Amsterdam)
var Cent_Amsterdam = ee.Feature(geometry);
Map.addLayer(Cent_Amsterdam, {}, 'Cent_Amsterdam');
Map.centerObject(Cent_Amsterdam, 10);
var first = ee.ImageCollection('LANDSAT/LC08/CO2/T1_L2')
.filterDate('2019-01-01', '2019-12-31')
.filterBounds(Cent_Amsterdam)
.sort('CLOUD_COVER')
.first();
Map.addLayer(first.clip(Cent_Amsterdam), {bands: ['SR_B4', 'SR_B3', 'SR_B2'], min: 7000, max: 15000});
This is the error:
Layer 2: Layer error: Feature, argument 'geometry': Invalid type.
Expected type: Geometry.
Actual type: Feature.
Just trying to get a Landsat overlay on Google Earth Engine of Amsterdam.
Please let me know how to fix this.

Related

Trying to use waypoints with JavaScript API

I'm new with MapHere, I see that with REST API side I can specify waipoints but I can't with JavaScript, I tried some parameters like 'via' but only admit one point:
var routingParameters = {
'routingMode': 'fast',
'transportMode': 'car',
// The start point of the route:
'origin': '36.8414197,-2.4628135',
'via': '37.9923795,-1.1305431',
// The end point of the route:
'destination': '40.4167047,-3.7035825',
// Include the route shape in the response
'return': 'polyline'
};
I saw an example on the main page of javascript web but I can't use waypoints:
var router = platform.getRoutingService(),
routeRequestParams = {
mode: 'fastest;car',
representation: 'display',
routeattributes: 'waypoints,summary,shape,legs',
maneuverattributes: 'direction,action',
waypoint0: '52.5160,13.3779', // Brandenburg Gate
waypoint1: '52.5206,13.3862' // Friedrichstraße Railway Station
};
Throwing the following error:
{"title":"Malformed request","status":400,"code":"E605001","cause":"Error while parsing request: 'origin' parameter is required\n","action":"","correlationId":"1c7bd525-b8af-4989-83a9-ab07f26a8c33"}
So, how I can send request for use waypoints?
EDIT
I saw the problem, when the .js create the url encode the second &via=
https://router.hereapi.com/v8/routes?xnlp=CL_JSMv3.1.18.1&apikey=***&routingMode=fast&transportMode=car&origin=50.1120%2C8.6834&destination=52.5309%2C13.3846&via=50.1234%2C8.7654%26via%3D51.2234%2C9.1123&return=polyline
If I decode & and = works perfectly
https://router.hereapi.com/v8/routes?xnlp=CL_JSMv3.1.18.1&apikey=***&routingMode=fast&transportMode=car&origin=50.1120%2C8.6834&destination=52.5309%2C13.3846&via=50.1234%2C8.7654&via=51.2234%2C9.1123&return=polyline
The JavaScript API does not yet (as of library version 3.1.18.1) support passing multiple waypoints, meaning passing an array of points to the via parameter. Your best bet around this lack of support would be to use the Routing REST API directly:
https://router.hereapi.com/v8/routes?
origin=52.550464,13.384223
&transportMode=car
&destination=52.477545,13.447395
&via=52.529791,13.401389
&via=52.513079,13.424392
&via=52.487581,13.425079
&apikey={YOUR_API_KEY}

Route Via Intermediate Waypoint - Passing a list of coordinates in via parameter

I need to pass a list of coordinates within parameters in via parameter, but i don't find the way. This is an example with only one pair of coordinates(lat, lng):
function calculateRoute (platform) {
var router = platform.getRoutingService(null, 8),
routeRequestParams = {
routingMode: 'fast',
transportMode: 'truck',
origin: '36.87689,-2.44138',
destination: '36.69630,-4.47968',
via: '38.99112,-1.86902', //LIST HERE!!!
return: 'polyline'
};
router.calculateRoute(
routeRequestParams,
onSuccessRoute,
onError
);
}
The url I'm hoping to get is like this:
https://router.hereapi.com/v8/routes?apikey=
{API_KEY}&routingMode=fast&transportMode=truck&origin=36.87689,-2.44138&via=38.99112,-1.86902&via=37.95862,-1.15538&destination=36.69630,-4.47968&return=polyline
As you can see via is repeat in the URL.
Many thanks!
The JavaScript API does not (yet) support multiple routing waypoints with regards to the Routing v8 API, meaning, it does not support passing a list of coordinates to the via parameter.
So your best bet is to target the Routing v8 REST API directly, like follow, and build a polyline out of the response:
# Note: line breaks and spaces are for readability only (they need to be removed)
https://router.hereapi.com/v8/routes?
origin=52.550464,13.384223
&transportMode=car
&destination=52.477545,13.447395
&via=52.529791,13.401389
&via=52.513079,13.424392
&via=52.487581,13.425079
&apikey={YOUR_API_KEY}
Don't know if it helps you, but
function calculateRouteFromAtoB (platform) {
var router = platform.getRoutingService(),
routeRequestParams = {
mode: 'fastest;car',
representation: 'display',
routeattributes : 'waypoints,summary,shape,legs',
maneuverattributes: 'direction,action',
waypoint0: '55.7520,37.6175',
waypoint1: '55.8941,37.4439',
waypoint2: '55.7982,37.9680'
};
router.calculateRoute(
routeRequestParams,
onSuccess,
onError
);
}
works for me.

No results from Azure Cognitive Services Image Search API when imageType query parameter is set to "Shopping"

I am trying to use the Microsoft Cognitive Services Image Search API to search for images and return ecommerce results.
Until recently, this was working perfectly, but now any searches I perform with the query parameter imageType: 'Shopping' come back empty. If I perform the same search with any other imageType filter, or without the filter at all, I get many results, including many results where insightsSourcesSummary.shoppingSourcesCount is greater than 0.
Here is the code I wrote to call the API:
const
promise = require('bluebird');
rp = require('request-promise');
var Bing = function () {};
Bing.prototype.imageSearch = function(q, count) {
var options = {
method: 'GET',
uri: "https://api.cognitive.microsoft.com/bing/v5.0/images/search",
qs: {
q: q,
count: count,
mkt: 'en-us',
safeSearch: 'Moderate',
imageType: 'Shopping'
},
headers: {
'Ocp-Apim-Subscription-Key': '****************'
},
json: true
};
return rp(options);
}
module.exports = Bing;
Again, I did not change any code between October 2016 when it was working, and now when it is not. Is this a new bug with the API or something I'm doing wrong?
Edited: a curl example for your convenience (you will need to specify a subscription key):
curl -H "Ocp-Apim-Subscription-Key:****************" "https://api.cognitive.microsoft.com/bing/v5.0/images/search?q=shoes&imageType=Shopping"

Meteor._wrapAsync doesn't seem to work with stripe api library

When I use _wrapAsync like so:
var stripeChargeCreate = Meteor._wrapAsync(_.bind(Stripe.charges.create,Stripe));
var charge = stripeChargeCreate({
amount: amount,
currency: "usd",
card: token,
description: description
});
I get the following error: Object # has no method 'createUrlData'
What am I missing?
Are you sure your bind is correct? _.bind(Stripe.charges.create,Stripe.charges) might work better.

Google Maps API v3 - How to specify "VehicleType"

I'm having some difficulties to specify Vehicle Type in my request. According to the documentation, it should look like something like this:
var request = {
origin:start,
destination:end,
travelMode: google.maps.DirectionsTravelMode.DRIVING,
TransitDetails: google.maps.TransitLine.TransitVehicle.VehicleType.BUS
};
But the folowing error shows up every time:
TypeError: google.maps.TransitLine is undefined
I think there's something wrong with my TransitDetails path.. but I can't figure out what exactly...
There is no TransitDetails-option for a directionsRequest.
There is only a TransitOptions-option where you can define departureTime and arrivalTime . The vehicleType is a part of the directionsResponse and is a simple string(e.g. BUS)

Resources