Mapbox Studio edit of style updated via REST API - mapbox

We created a dataset, tileset, and style via Mapbox Studio
It was very simple with only one colored layer.
Then we used the REST API to add many layers.
For example, (reference see: https://www.mapbox.com/api-documentation/#update-a-style)
The style.json file has many new layers that were generated via a python script.
"layers": [
...
{"id": "bid_id-WPLNS", "source": "composite", "paint": {"fill-color": "rgba(62,129,54,0.4)"}, "source-layer": "Business_Improvement_Districts", "interactive": true, "filter": ["==", "bid_id", "WPLNS"], "layout": {"visibility": "visible"}, "type": "fill"},
{"id": "bid_id-WSTSH", "source": "composite", "paint": {"fill-color": "rgba(17,31,177,0.4)"}, "source-layer": "Business_Improvement_Districts", "interactive": true, "filter": ["==", "bid_id", "WSTSH"], "layout": {"visibility": "visible"}, "type": "fill"},
{"id": "bid_id-WSTSQ", "source": "composite", "paint": {"fill-color": "rgba(143,124,110,0.4)"}, "source-layer": "Business_Improvement_Districts", "interactive": true, "filter": ["==", "bid_id", "WSTSQ"], "layout": {"visibility": "visible"}, "type": "fill"},
...
then we issue a REST HTTP PATCH to update the style:
curl -X PATCH
"https://api.mapbox.com/styles/v1/ryozzopanodex/cistmnflb002l2woxcfbgyl3m?access_token=WRITE-TOKEN-HERE"
--data #style.json --header "Content-Type:application/json"
For the result:
see https://city.tidalforce.org/bid
Question WHY when I go to Mapbox Studio and edit the style, do I NOT see the REST API created layers?
I only see the original layers that were created in Studio. If I edit and save, it appears that all the REST API created layers would be overwritten.
Please let us know if there is a way to edit the new layers via Mapbox Studio (which we love!)

it is possible that you are using the REST API to update the published version of the style, but you're viewing the draft version of the style when you attempt to edit the style in Mapbox Studio. Try using the 'revert draft to last published' action from the list or style view page:
revert to last published
and then try to edit the style. Mapbox Studio automatically creates drafts for all styles so that users don't accidentally break styles that are used in production. Once you're satisfied with changes to your draft, you can apply the draft changes to the published style with the 'publish' button in the styl editor.

Related

Mapbox - How to properly use the Tilesets API

I am trying to update my existing tileset with new data. In postman, I sucessfully send the following;
https://api.mapbox.com/tilesets/v1/sources/{{usermame}}/testing?access_token={{admin-access-token}}
In the body, I have added a new line delimited geojson, as required, with the following key/value pair;
key: file
value: file_nd.geojson
As a reply I get the following;
status: ok
{
"id": "mapbox://tileset-source/{{username}}/testing",
"files": 1,
"source_size": 1131168,
"file_size": 1131168
}
When I go to the tileset tab on the mapbox website, the modified time does not change and the data is not updated. I did notice though that if I look at tileset sources in postman using the following;
https://api.mapbox.com/tilesets/v1/sources/{{username}}?access_token={{admin-access-token}}
This is returned;
{
"id": "mapbox://tileset-source/{{username}}/testing",
"size": 1131168,
"files": 1
},
So I am guessing that it has not yet been converted to a tileset. I cannot see in the documentation how to trigger the conversion via the API. Any help appreciated.

adding openweather data to mapbox map

So im trying to add weather data to my mapbox map. Im using for the data the openweather api. Im trying to add the data via adding a layer with the weather data tiles. Here's my current code: ` var map1 = "https://tile.openweathermap.org/map/temp_new/{z}/{x}/{y}.png?appid=e7fef929605b6a73c6921e4fec83f6ce"
map.on('load', function(){
map.addLayer({
"id": "simple-tiles",
"type": "raster",
"source": {
"type": "raster",
"tiles": ["https://tile.openweathermap.org/map/temp_new/{z}/{x}/{y}.png?appid=e7fef929605b6a73c6921e4fec83f6ce"],
"tileSize": 256
},
"minzoom": 0,
"maxzoom": 22
});
});`
So if i do it like this it works totaly fine, but if i try to add weather tileset trough a link provided on the openweather website it doesnt work. Also the link is quiet different. For example i want to add this map: http://maps.openweathermap.org/maps/2.0/weather/PA0/{z}/{x}/{y}?date=1527811200&appid={API key} it doesnt work. And yes i changed the api key placeholder with my api key. So any suggestions why its not working with this other link and how to fix that problem. Maybe iam just stupid but thanks in advance.

Reports for Flutter test_driver execution

I need to generate a report about how much tests was executed, how much failed, why test was failed. Is there some option to do it with test_driver?
We can generate json report for flutter unit tests with command flutter test --machine. Is there something same for flutter drive?
Although flutter driver doesn't generate a full-fledged test summary report out-of-box, there's an alternative way to do it using flutter_gherkin plugin. This plugin makes use of ATDD style of writing integration tests leveraging flutter driver and its methods.
Checkout the example from plugin's repo.
This plugin has a configuration file (just like instrumentation file in Google Espresso) which has a reporter parameter to specify json reporter that generates report in json format.
Below is the content of generated json report:
[{
"keyword": "Feature",
"uri": "./test_driver/features/custom_parameter_example.feature",
"id": "custom parameter example",
"name": "Custom Parameter Example",
"description": "",
"line": 0,
"elements": [{
"keyword": "Scenario",
"type": "scenario",
"id": "custom parameter example;custom colour parameter",
"name": "Custom colour parameter",
"description": "",
"line": 3,
"steps": [{
"keyword": "Given ",
"name": "I pick the colour red",
"line": 4,
"result": {
"status": "passed",
"duration": 6000000
}
}, {
"keyword": "Given ",
This report can then be converted into html report using cucumber-html-reporter per your requirement.
This approach sounds a bit tedious and the format may or may not be the way you want, because you might need to re-write your tests in Given When Then format in order for json report to be generated, but you may give this approach a try to see if this works for you.
Yes, reports can be generated by setting paths in the test driver class, where the report path is initialized.
import 'package:integration_test/integration_test_driver.dart'
as integration_test_driver;
Future<void> main() async {
/// Repports are generated on given path, once all tested passed,
integration_test_driver.testOutputsDirectory =
'integration_test/reports';
await integration_test_driver.integrationDriver(
timeout: const Duration(minutes: 60));
}
Note: This will work using the flutter drive command.

SharePoint 2013 - Associating Site Columns With Content Types Using the REST API

I'm trying to use the REST API to programatically create site columns and content types. Everything works fine until I try to associate my site columns with my content types.
By this point in my code the site columns and content types already exist...
I am sending a POST to the following URL...
http://mydevmachine/sites/claimsreports/_api/web/ContentTypes('0x01003E9D5AD94A5DCD46876B7BFFCEA9B60C')/FieldLinks
Here is the information I am sending in the request body...
{
"__metadata": {
"type": "SP.FieldLink"
},
"Id": "9400d057-ba2c-4ab4-9ce0-671b858fd849",
"Name": "BusinessCategory",
"Hidden": false,
"Required": false
}
Here is the error I get back in response...
{"error":{"code":"-2147467261, System.ArgumentNullException","message":{"lang":"en-US","value":"Value cannot be null.\r\nParameter name: parameters"}}}
I have tried several other options without success. For example, I have tried using "__metadata" : { "type": "SP.FieldLinkCreationInformation"} but everything I try with this __metadata type result in this error...
{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A type named 'SP.FieldLinkCreationInformation' could not be resolved by the model. When a model is available, each type name must resolve to a valid type."}}}
It sounds like SharePoint is telling me that this "type" is invalid. It seems like this should be possible with SharePoint 2013 since the documentation seems to imply that its possible...
documentation
If anyone has any ideas I would be greatful for the suggestions. Thanks!
Based on the documentation, I would try that:
Endpoint (note the /add at the end):
http://mydevmachine/sites/claimsreports/_api/web/ContentTypes('0x01003E9D5AD94A5DCD46876B7BFFCEA9B60C')/FieldLinks/add
Body (wrap your properties in a parameters property):
{"parameters":
{
"__metadata": {"type": "SP.FieldLink"},
"Id": "9400d057-ba2c-4ab4-9ce0-671b858fd849",
"Name": "BusinessCategory",
"Hidden": false,
"Required": false
}
}

How to construct a permalink for objects returned by Facebook's new Graph API?

Facebook Graph API allows getting Facebook objects like posts, videos etc in JSON from. Here is an example of a post: (taken from the documentation):
{
"id": "719323658_129694190395214",
"from": {
"name": "Rabia Yalcinkaya",
"id": "719323658"
},
"message": "COK MUHTESEM!!!",
"picture": "http://external.ak.fbcdn.net/safe_image.php?d=41762b7121ee68754ebea48dee4568aa&w=130&h=130&url=http%3A%2F%2Fats.vimeo.com%2F192%2F882%2F19288238_200.jpg",
"link": "http://vimeo.com/5646785",
"source": "http://vimeo.com/moogaloop.swf?clip_id=5646785",
"name": "Watermelon carving",
"caption": "vimeo.com",
"description": "Me carving a watermelon.",
"icon": "http://static.ak.fbcdn.net/rsrc.php/z9XZ8/hash/976ulj6z.gif",
"type": "video",
"created_time": "2010-06-23T10:58:17+0000",
"updated_time": "2010-06-23T10:58:17+0000",
"likes": 1
},
How does one construct a url which allows you to link back to the original video (or other types) on Bret's wall on Facebook? something in the form of
http://www.facebook.com/<USER_ID>/video/<VIDEO_ID>
Thanks,
Boaz
in the actions field there is the link field (for each available action) which happens to contain the permalink to the given post. However be sure to inspect this before relying on it - it might change. I've only used it with "comment" and "like".
Apart from that you'd have to construct it manually. For users that have their username set (i.e. their profile is accessible via facebook.com/username, it works with:
http://facebook.com/USERID/posts/POSTID
For everything else:
http://www.facebook.com/permalink.php?id=USERID&v=wall&story_fbid=POSTID
Source: http://forum.developers.facebook.net/viewtopic.php?pid=316384
Note that the POSTID is in the form USERID_POSTID, so you'd have to strip the first part.