I'm attempting to use this JSON from a SpaceX API to display the locations of all the SpaceX launch sites on a Mapbox map using Mapbox-GL. When I attempt to load this into a dataset in Mapbox Studio I get an error that says: Input failed. "type" member required on line 1.
I assume this is due to the way that the JSON is structured i.e. it doesn't have GeoJSON properties.
How can I easily adapt this JSON and convert it into GeoJSON that works with Mapbox?
The JSON file you provided isn't a valid GeoJSON. You can read more about the specification of the format here: http://geojson.org/
You would want a small script to transform the SpaceX JSON file into valid GeoJSON. Currently a single record looks like this:
{
"id": "ccafs_slc_40",
"full_name": "Cape Canaveral Air Force Station Space Launch Complex 40",
"status": "active",
"location": {
"name": "Cape Canaveral",
"region": "Florida",
"latitude": 28.5618571,
"longitude": -80.577366
},
"vehicles_launched": [
"Falcon 9"
],
"details": "SpaceX primary Falcon 9 launch pad, where all east coast Falcon 9s launched prior to the AMOS-6 anomaly. Initially used to launch Titan rockets for Lockheed Martin. Back online since CRS-13 on 2017-12-15."
}
What you probably want is a Feature with a geometry type of Point like this:
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-80.577366, 28.5618571]
},
"properties": {
"id": "ccafs_slc_40",
"full_name": "Cape Canaveral Air Force Station Space Launch Complex 40",
"status": "active",
"location": {
"name": "Cape Canaveral",
"region": "Florida"
},
"vehicles_launched": ["Falcon 9"],
"details":
"SpaceX primary Falcon 9 launch pad, where all east coast Falcon 9s launched prior to the AMOS-6 anomaly. Initially used to launch Titan rockets for Lockheed Martin. Back online since CRS-13 on 2017-12-15."
}
}
After you transformed each record of your original array, you need to wrap them in a FeatureCollection in order for mapbox-gl to render it:
{
"type": "FeatureCollection",
"features": [
//...
]
}
Related
I want to know how to use NSGI-LD to upload an image even though these static files are not stored in Orion Context Broker or Mongo. I want to know if there is a way to configure the NSGI-LD to forward the images to AWS S3 Buck or another location?
As you correctly identified, binary files are not a good candidate for context data, and should not be held directly within a context broker. The usual paradigm would be as follows:
Imagine you have a number plate reader library linked to Kurento and wish to store the images of vehicles as they pass. In this case the event from the media stream should cause two separate actions:
Upload the raw image to a storage server
Upsert the context data to the context broker including an attribute holding the URI of the stored image.
Doing things this way means you can confirm that the image is safely stored, and then send the following:
{
"vehicle_registration_number": {
"type": "Property",
"value": "X123RPD"
},
"image_download": {
"type": "Property",
"value": "http://example.com/url/to/image"
}
}
The alternative would be to simply include some link back to the source file somehow as metadata:
{
"vehicle_registration_number": {
"type": "Property",
"value": "X123RPD",
"origin": {
"type": "Property",
"value": "file://localimage"
}
}
}
Then if you have a registration on vehicle_registration_number which somehow links back to the server with the original file, it could upload the image after the context broker has been updated (and then do another upsert)
Option one is simpler. Option two would make more sense if the registration is narrower. For example, only upload images of VRNs for cars whose speed attribute is greater than 70 km/h.
Ontologically you could say that Device has a relationship to a Photograph which would mean that Device could have an additional latestRecord attribute:
{
"latestRecord": {
"type": "Relationship",
"object": "urn:ngsi-ld:CatalogueRecordDCAT-AP:0001"
},
}
And and create a separate entity holding the details of the Photograph itself using a standard data model such as CatalogueRecordDCAT-AP which is defined here. Attributes such as source and sourceMetadata help define the location of the raw file.
{
"id": "urn:ngsi-ld:CatalogueRecordDCAT-AP:0001",
"type": "CatalogueRecordDCAT-AP",
"dateCreated": "2020-11-02T21:25:54Z",
"dateModified": "2021-07-02T18:37:55Z",
"description": "Speeding Ticket",
"dataProvider": "European open data portal",
"location": {
"type": "Point",
"coordinates": [
36.633152,
-85.183315
]
},
"address": {
"streetAddress": "2, rue Mercier",
"addressLocality": "Luxembourg",
"addressRegion": "Luxembourg",
"addressCountry": "Luxembourg",
"postalCode": "2985",
"postOfficeBoxNumber": ""
},
"areaServed": "European Union and beyond",
"primaryTopic": "Public administration",
"modificationDate": "2021-07-02T18:37:55Z",
"applicationProfile": "DCAT Application profile for data portals in Europe",
"changeType": "First version",
"source": "http://example.com/url/to/image"
"sourceMetadata": {"type" :"jpeg", "height" : 100, "width": 100},
"#context": [
"https://smartdatamodels.org/context.jsonld"
]
}
Try to use FactSet to show multiple data inside my AdaptiveCard
this is when i retrieve my data from Database and create my json object
and here is where i create my Adaptive Cards
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0",
"type": "AdaptiveCard",
"speak": "Your flight is confirmed for you and 3 other passengers from San Francisco to Amsterdam on Friday, October 10 8:30 AM",
"body": [
{
"type": "FactSet",
"facts": [
{
"$data": "${dialog.productFamily}",
"title": "${key}",
"value": "${value}"
}
]
}
]
}
And this is the error
getProduct.en-us.lg:Unexpected character at Path body[0].facts[0].$data, line 14, position 5 when parsing
Adaptive card templating is not implemented in the bot framework SDK yet.
https://github.com/microsoft/botframework-sdk/issues/6477
I have followed the Postman tutorial for the model derivative API, specifically for extracting metadata. I used a .dxf file, since I want to know if it is possible to retrieve perimeter, length/width properties based off the file.
I received a 200 response and it gave me a massive list of objects w/ their respective objectid's. Basically I got back a ton of these:
{
"objectid": 253,
"name": "Line [108]",
"externalId": "108",
"properties": {
"3D Visualization ": {
"Material": "ByLayer"
},
"General": {
"Color": "ByLayer",
"Handle": "108",
"Layer": "color#000000ff",
"Linetype": "BYLAYER",
"Linetype scale": "1.000",
"Lineweight": "ByLayer",
"Name ": "Line",
"Plot style": "ByColor",
"Thickness": "0.000 mm",
"Transparency": "ByLayer"
},
"Geometry": {
"Angle": "192.931 deg",
"Length": "0.088 mm"
}
}
}
The .dxf file I tested was as simple as possible and it looks like this image:
How can I retrieve the perimeter of this image? Is it possible to retrieve other specific geometric properties that I specify?
How can I know what part of the .dxf file each objectid is referring to?
Although it looks simple, the polyline (?) is probably being tessellated, resulting in a large number of small lines. Have you tried the original DWG file? Can you try that with viewer.autodesk.com?
I am trying to extract data from a 2d Cad drawing. Essentially I would like to find the x/y coordinates of every element. However, the data does not show this information.
I am using the modelderivative/v2/designdata/{{urn}}/metadata/{{guid}}/properties endpoint to extract the data itself.
Here is an example of the output this gives
{
"objectid": 3308,
"name": "Text [67AC]",
"externalId": "67AC",
"properties": {
"AnnotationScaling": {
"Annotative": "No"
},
"General": {
"Color": "ByLayer",
"Handle": "67ac",
"Layer": "IMAGE-HYPERLINKS",
"Linetype": "ByLayer",
"Linetype scale": "1.000",
"Lineweight": "ByLayer",
"Name ": "Text",
"Plot style": "ByColor",
"Thickness": "0.000",
"Transparency": "ByLayer"
},
"Hyperlinks": {
"Description": ".\\R0010020.JPG",
"Name": ".\\R0010020.JPG"
},
"Misc": {
"Backward": "No",
"Upside down": "No"
},
"Text": {
"Contents": "R0010020.JPG",
"Height": "0.050",
"Justify": "Left",
"Obliquing": "0.000 deg",
"Rotation": "111.348 deg",
"Style": "Standard",
"Width factor": "1.000"
}
}
},
As you can see, there is no key 'Geometry'
Can anyone point me in the right direction on how I can extract the object positioning data for a 2d Cad drawing? Could it be that the drawing itself needs to implicitly set this information?
Here is an example of what I'm seeing in the Cad drawing itself.
Cad Output
There is no mention of the correct keys "Position X", "Position Y" in the modelderivative output above. Can anyone explain why this might be? Am I exporting it incorrectly? Or does Forge remove this information?
I am using PHP and getting the data server-side.
I exported another test model and found the following was generated
"Geometry": {
"Area": "1131855.821",
"Circumference": "3771.382 mm",
"Diameter": "1200.468 mm",
"Radius": "600.234 mm"
}
But there are no X/Y/Z coordinates in this data.
You can parse the individual primitives of your 2D drawing on the client side based on this blog post: https://forge.autodesk.com/blog/working-2d-and-3d-scenes-and-geometry-forge-viewer.
Parsing the drawing geometry on the server-side would be a bit more involved, since the file format used in Forge Viewer is not publicly documented. You could use tools like https://github.com/Autodesk-Forge/forge.commandline-nodejs, but I'm not sure if there are alternatives for PHP.
I'm using cdh5 quickstart vm and I have a file like this(not full here):
{"user_id": "kim95",
"type": "Book",
"title": "Modern Database Systems: The Object Model, Interoperability, and
Beyond.",
"year": "1995",
"publisher": "ACM Press and Addison-Wesley",
"authors": {},
"source": "DBLP"
}
{"user_id": "marshallo79",
"type": "Book",
"title": "Inequalities: Theory of Majorization and Its Application.",
"year": "1979",
"publisher": "Academic Press",
"authors": {("Albert W. Marshall"), ("Ingram Olkin")},
"source": "DBLP"
}
and I used this script:
books = load 'data/book-seded.json'
using JsonLoader('t1:tuple(user_id:
chararray,type:chararray,title:chararray,year:chararray,publisher:chararray,source:chararray,authors:bag{T:tuple(author:chararray)})');
STORE books INTO 'book-no-seded.tsv';
the script works , but the generated file is empty, do you have any idea?
Finally , only this schema worked : If I add or remove a space different from this configuration then i gonna have an error( i also added "name" for tuples and specified "null" when it was empty, and changed the order between authors and source, but even without this congiguration it will still be wrong)
{"user_id": "kim95", "type": "Book","title": "Modern Database Systems: The Object Model, Interoperability, and Beyond.", "year": "1995", "publisher": "ACM Press and Addison-Wesley", "authors": [{"name":null"}], "source": "DBLP"}
{"user_id": "marshallo79", "type": "Book", "title": "Inequalities: Theory of Majorization and Its Application.", "year": "1979", "publisher": "Academic Press", "authors": [{"name":"Albert W. Marshall"},{"name":"Ingram Olkin"}], "source": "DBLP"}
And the working script is this one :
books = load 'data/book-seded-workings-reduced.json'
using JsonLoader('user_id:chararray,type:chararray,title:chararray,year:chararray,publisher:chararray,authors:{(name:chararray)},source:chararray');
STORE books INTO 'book-table.csv'; //whether .tsv or .csv
try STORE books INTO 'book-no-seded.tsv' using USING org.apache.pig.piggybank.storage.JsonStorage();
You need to bu sure that the LOAD schema is good. You can try to do a DUMP books to quick check.
We had to be careful with the input data and the schema when we used the Pig JsonLoader for this tutorial http://gethue.com/hadoop-tutorials-ii-1-prepare-the-data-for-analysis/.