I have a JSON file that contains the geometric information about the sketch. The file is in the following format:
"Name": Name of the geometric entity
"Type": Type of the entity, either a line or an arc (a circle is represented by an arc and a rectangle as a set of 4 such dictionaries of type line.)
If the entity is of the type line, then the dict would contain the coordinates of the starting and ending points of the line.
If it is of the type arc, then the dict would contain the radius, the coordinates of the center and the starting and ending points of the arc.
Here is an example of each type:
Type == Line
"Name": "Line8",
"Type": "Line",
"Start Point": [
0.0,
-13.694950218796503,
127.7623417068559
],
"End Point": [
0.0,
-12.800696621739458,
121.82935674950514
],
"Length": 5.999999999999998
Type == Arc
"Name": "Arc4",
"Type": "Arc",
"CentrePoint": [
0.0,
0.0,
0.0
],
"Radius": 137.0,
"RotationAngle": 0.0,
"StartAngle": 1.5474413367198918,
"EndAngle": 1.5941513168699013,
"Circumference": 6.399267280551308
A JSON file will contain multiple such dictionaries for multiple geometric entities that make up a geometric sketch.
I want to create a bounding box around that sketch and need its coordinates.
My initial approach was to just take the min and max values of the x, y and z coordinates from these dictionaries to define a bounding box. But by doing this I might end up missing the curves in the arcs since I only have information about the center of the arc and not the points on the arc.
How should I go about getting the bounding box coordinates given this JSON file?
Related
I'm creating a interactive map of my campus, the ideia is to replicate what I did on uMaps, in this link. The geojson was downloaded from UMap and I'm using the coordinates that came with it.
My first issue is my coordinates in the json, originally were a GeoJson, are sorted wrongly, my long came first then lat, thus when parse Google Maps can't read properly.
Json:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "Almoxarifado / Patrimônio"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-52.163317,
-32.075462
],
[
-52.163884,
-32.075467
],
[
-52.163883,
-32.075336
],
[
-52.163321,
-32.075332
],
[
-52.163317,
-32.075462
]
]
]
}
},
{
...
},
{
...
},
...
]
}
So, I have to flip the coordinates lines to proper put in my Google Maps Api.
And my second issue is chaging the "type" key to "layer", for a better sepation layers in my app.
I've tried:
.features[] | .["type"] |= .["new value"]
How ever that changes the value and only accepts float values
Any help, advice or guidance would be greatly appreciated.
Part 1
flip the coordinates lines
For clarity and ease of testing, let's define a helper function:
# input: a JSON object with a coordinates array of arrays of pairs
def flip: .coordinates |= map(map(reverse)) ;
or even better - before invoking reverse, check the array has the expected length, e.g.:
def flip:
.coordinates
|= map(map(if length == 2 then reverse
else error("incorrect length: \(length)")
end)) ;
To flip the coordinates, we can now simply write:
.features[].geometry |= flip
Part 2
change the "type" key to "layer"
{layer: .type} + .
| del(.type)
Putting it together
{layer:.type} + .
| del(.type)
| .features[].geometry |= flip
Eg: [360590, 555610] - [lng, lat] in meters from google map api
- GeoJson data
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
360590,
555610
],
[
360590,
555555.0128
],
[
360590,
555540
],
[
360592.4439,
555540
],
[
360600,
555540
],
[
360600,
555518.8277
]
]
]
]
}
}
]
}
here, [360590, 555610] - [X, Y] coordinates is in meters, Now we need to display this coordinates on google map, Is there any solution for this?
also we must have to use addGeoJson or loadGeoJson method because we have 200MB data in GeoJson file.
Now we need to display this coordinates on google map, Is there have any solution for this?
Are you sure that these coordinates are in a meter?
It may be EPSG: 27700 or EPSG:4326 so you can try with it.
and you this link
QGIS
for convert coordinates and It might be useful for you.
Mapbox has a Utility class that can perform the conversion of meters to latitude/longitude for you:
public static Vector2d MetersToLatLon(Vector2d m)
Converts Spherical Mercator EPSG:900913 in xy meters to WGS84 lat/lon.
public static Vector2d LatLonToMeters(Vector2d v)
Converts Vector2d struct, WGS84 lat/lon to Spherical Mercator EPSG:900913 xy meters.
If you're looking to do the conversion yourself, then a simple approach is the following:
Assume the earth is a sphere with a circumference of 40,075km.
Length in meters of 1° of latitude is always 111.32km
Length in meters of 1° of longitude = 40,075 km * cos(latitude) / 360
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.
Can I use coordinates [Lat,Long, Elevation, Time] in a GeoJSON file so that file can be used by any other application?
{ "type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[102.0, 0.0,805,"22-08-2016 13:04:04"],
[103.0, 1.0,806,"22-08-2016 13:05:04"],
[104.0, 0.0,804,"22-08-2016 13:06:00"],
[105.0, 1.0,808,"22-08-2016 13:07:40"]]
},
"properties": {
"prop0": "value0",
"prop1": 0.0
}
}
// "Using elevation and time in coordinate array elevation as numeric and time in string format
This would be the geoJSON specification.
As they say in the section about extending geoJSON you can extend to add foreign members, but anything that alters the structure of the already defined types is referred to as versioning geoJSON, and as such that kind of object should not be called a geoJSON.
You can check the specifications they define for a position array.
TL;DR you can, but it wont be a geoJSON anymore and parsers are not guaranteed to work with it.
I've textured a cube in blender 2.6. I assigned a color map from file cube.png to the cube. I assigned a normal map from file bump.png to the cube. I set the normal map to be a normal map and to influence normals. Blender displays the normal mapping correctly. I've then used fbx-conv 0.01 with option -o g3dj to get a readable file. The only warning I got was the RrSs thingie, which afaik can be safely ignored. I then opened the file to inspect the result. The texture structure does not reflect the normal map:
"materials": [
{
"id": "Material",
"diffuse": [ 0.800000, 0.800000, 0.800000],
"emissive": [ 0.800000, 0.800000, 0.800000]
},
{
"id": "Material__bump_png",
"diffuse": [ 0.800000, 0.800000, 0.800000],
"emissive": [ 0.800000, 0.800000, 0.800000],
"textures": [
{
"id": "bump_png",
"filename": "bump.png",
"type": "DIFFUSE"
}
]
}
],
So basically it exports the last texture of the texture stack, and it exports it with standard settings, not as a diffuse map.
What do I have to do (in Blender settings, I suppose) to have normal mapping exported correctly using fbx-conv?
3D Model with Diffuse AND Normalmap texture suggests that normal map export should be supported. probably I am doing something wrong in blender?
thanks a lot
Wolfgang
We do have problems with the exported Models from Blender as well. And I have never seen the fbx-conv exporting the normal map correctly (probably, cause I am doing smth. wrong)
a solution would be to convert the fbx into g3dj, put in the normal map manually.
},
{
"id": "stone_phong",
"diffuse": [ 1.000000, 1.000000, 1.000000],
"specular": [ 0.204000, 0.163487, 0.079152],
"textures": [
{
"id": "file5",
"filename": "rock_diff.png",
"type": "DIFFUSE"
},
{
"id": "stone_norm",
"filename": "rock_norm.png",
"type": "NORMAL"
}
]
},
as described in the tutorial from xoppa. And use g3dj for testing. afaik fbx-conv can convert g3dj into g3db as well.
The disappointing thing you'll figure out, is that it still does not use the normal maps in the shader.
[Edit:] A closer look in the G3ModelLoader tells me that instead of NORMAPMAP you have to use NORMAL to make the loader associate the normal texture attribute as such. I corrected that in the g3dj example above