I am trying to define a rotated pole projection in Proj4JS where the north pole is now is 48N and 176E. I haven't been able to find any other example of rotated-poles in Proj4JS so I have tried to convert one I found for PROJ.4.
proj4.defs('myProjection', '+proj=ob_tran +o_proj=latlon +o_lon_p=-176 +o_lat_p=48 +lon_0=0 +a=1 +to_meter=0.0174532925199');
That line of JS is run without problem, but when I try to use that projection
proj4('EPSG:4326', 'myProjection', [175, -41]);
I get this error
uncaught exception: myProjection
I've tried replacing the projection definition the one for WGS84 and it works fine, so I believe my use of the function is correct, it's the parameters in that string that I am unsure of.
I think what you want is the so-called Azimuthal Equidistant projection. It's the best choice for measuring true distances radiating away from a center point.
If this is what you're looking for, I asked a similar question a while back over on GIS.SE, and for the coordinate you provided (48N, 176E), you could declare the Proj4js projection definition as so..
Proj4js.defs["CUSTOM:10001"] = "+proj=aeqd +lat_0=48.0 +lon_0=176.0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
I hope it helps.
Related
I am having trouble mapping Nebraska school districts in D3 (v4). (See bl.ock here.) I can map Nebraska counties no problem, but the same code modified for school districts--and pointing to a school district TopoJSON file--gives me a blank page.
Here's how I created the JSON, based on Mike Bostock's excellent instructions :
curl "https://www2.census.gov/geo/tiger/GENZ2017/shp/cb_2017_31_unsd_500k.zip" -o cb_2017_31_unsd_500k.zip
unzip -o cb_2017_31_unsd_500k.zip
shp2json cb_2017_31_unsd_500k.shp -o ne_district.json
ndjson-split "d.features" < ne_district.json > ne_district.ndjson
ndjson-map "d.id = d.properties.GEOID, d" < ne_district.ndjson > ne_district-id.ndjson
geo2topo -n districts=ne_district-id.ndjson > ne_district-id-topo.json
And here's my projection:
var projection = d3.geoConicConformal()
.parallels([40, 43])
.rotate([100, 0])
.scale(8000);
Thanks for your help and apologies in advance for anything important I left out!
The issue is you haven't finished setting your projection parameters. You have rotate the map, which is how you should center a conic projection along the x axis. But you haven't centered the map on the y axis, it is centered on the equator. You
For a conical projection, you can do this one of three ways:
Center the map on a central latitude : projection.center([0,y])
You don't need to use .center with an x value because the map is already centered on the x by rotation, rotation and centering are cumulative
Rotate the map to a central latitude and longitude: projection.rotate([-x,-y])
On a conical projection the rotation on the meridian does not warp the map (generally), we rotate by the negative as we move the earth under us. This option does slightly distort the map relative to the other options - this may be preferrable.
Use the projection translation to center the map
The easiest way is to translate the result while automatically scaling (though you can do this manually too) with projection.fitSize or projection.fitExtent. These methods modify projection.scale and projection.translate. As with centering with .center, you need to keep your rotation - otherwise you'll get an odd tilt to the map.
These methods set translate and scale to appropriate values so that your map area contains the desired features:
var featureCollection = topojson.feature(ne, ne.objects.districts);
projection.fitSize([width,height],featureCollection);
These methods must take objects, not arrays, so we use the featureCollection, not the features as an array
Both methods take an array specifying the size to stretch a provided geojson object over:
projection.fitSize([mapwidth,mapheight],geojsonObject)
projection.fitExtent([[left,top],[right,bottom]],geojsonObject)
Here's an updated gist using fitSize.
I've tried modifying the FetchPickAndPlace-v1 OpenAI environment to replace the cube with a pair of scissors. Everything works perfectly except for the fact that my custom mesh seems to jitter a few millimeters in and out of the table every few time steps. I've included a picture mid-jitter below:
As you can see, the scissors are caught mid-way through the surface of the table. How can I prevent this? All I've done is switch out the code for the cube in pick_and_place.xml with the asset related to the scissor mesh. Here's the code of interest:
<body name="object0" pos="0.0 0.0 0.0">
<joint name="object0:joint" type="free" damping="0.01"></joint>
<geom size="0.025 0.025 0.025" mesh="tool0:scissors" condim="3" name="object0" material="tool_mat" class="tool0:matte" mass="2"></geom>
<site name="object0" pos="0 0 0" size="0.02 0.02 0.02" rgba="1 0 0 1" type="sphere"></site>
</body>
I've tried playing around with the coordinates of the position and geometry but to no avail. Any tips? Replacing mesh="tool0:scissors" with type="box" gets rid of the problem entirely but I'm back to square one.
As suggested by Emo Todorov in the MuJoCo forums:
Replace the ground box with a plane and
use MuJoCo 2.0. The latest version of the collision detector
generates multiple contacts between a mesh and a plane, which
results in more stable simulation. But this only works for
plane-mesh, not for box-mesh.
The better solution is to break the mesh into several meshes, and include them as multiple geoms in the same body. Then MuJoCo will construct the convex hull of each sub-mesh, resulting in multiple contact points (even without the special plane mechanism mentioned above) and furthermore it will be a better approximation to the actual object geometry.
Can someone give me the formula?
I have a vector3d which represents the position of a vertex in local coordinates, I have a Matrix3d that represents the rotation and position of the object which this vertex is part of it's geometry, how do I convert the local position of this vertex to the coordinates of the world?
now it's working, I had a problem with keeping the original vertex3d, and I played with the order and this is working, thank you very much, here is the code, I did have to use m2.invert(); here is the code:
var m3d:Matrix3D = new Matrix3D();
obj.Transform.copyToMatrix3D(m3d);
var m2:Matrix3D = new Matrix3D();
m2.append(m3d);
m2.invert();
m2.prependTranslation(obj.BoundingBox[i].x,obj.BoundingBox[i].y,obj.BoundingBox[i].z);
obj.BoundingBox[i] = new Vector3D(m2.position.x,m2.position.y,m2.position.z);
in fact as I did it in the first place was also OK:
var m3d:Matrix3D = new Matrix3D();
obj.Transform.copyToMatrix3D(m3d);
m3d.invert();
obj.BoundingBox[i] = m3d.transformVector(obj.BoundingBox[i]);
The only thing I was missing was the invert(); and I wish I knew what it is for...
Some people told me I have to append (or prepend) the object matrix and then the world matrix, which makes sense, but adding the world matrix only caused me problems, while the invert(); made it good, but why?
Vesper, you are the one suggested it, thanks but why?
I know why, someone experienced gave me the answer: the camera shows everything mirrored, when you go left the world seems to be moving right, so you need to invert.
I'm begining to work with turf an leaflet and I found my first problem, I need calculate the length of a polyline whit this style:
image of my line
However I can't calculate his length with the function gives turf:
turf.lineDistance(line, 'kilometers');
This doesn't nothing, line is Linestring in the examples but my line is MultilinestriNg, will be for this?,
thanks, I hope good comments :)
turf only accept "LineString" for this action.
https://www.npmjs.com/package/turf-line-distance
You need convert your "Multilinestring" to "LineString" for example using Qgis.
I imagine this is a simple problem for anyone really familiar with Cesium's CZML files. I'm just trying to display a series of lat/long/alt points as a flight path using Cesium. Can someone tell me what the "position" tag should look like?
Unless I'm looking in the wrong places, I don't see a lot of examples for CZML. So it's hard to know what tags can be used and how to use them (and the Java console doesn't show the errors if you get them wrong).
In the Sandcastle CZML example on the Cesium website, the relevant section looks like this:
"position" : {
"interpolationAlgorithm" : "LAGRANGE",
"interpolationDegree" : 1,
"epoch" : "2012-08-04T16:00:00Z",
// Trimmed to just 2 points
"cartesian" : [0.0, -2379754.6637012, -4665332.88013588, 3628133.68924173,
3894.996219574019, -2291336.52323822, -4682359.21232197, 3662718.52171165]
}
If it's two points, why are there 8 values? If it was ECEF coordinates, I would expect only three per point...
For example, when I tried this, I got an "uncaught error" message in the console... which isn't very helpful:
"cartographic" : [-1.472853549, 0.589580778, 1000,
-1.472962668, 0.589739552, 1000 ]
According to the documentation, cartographic takes (long, lat, height) where long and lat are in radians and height is in meters.
The first coordinate is in each set of 4 is time, so it's actually (t, x, y, z). In the example you posted, t is the number of seconds after the specified epoch that the waypoint exists.
You can also use cartographicRadians or cartographicDegrees, but they would still be specified as (t, lon, lat, alt).
If you want to draw a route that is not time-dynamic (i.e. just a static line) you can use the polyline CZML object instead; which has a list of x/y/z positions without time.
Matthews answer is correct, took a littke bit of tweaking to get it working so for others looking at this here is an example showing cartographicDegrees in use.
"position": {
"interpolationAlgorithm": "LAGRANGE",
"interpolationDegree": 1,
"epoch": "2012-08-04T16:00:00Z",
"cartographicDegrees": [
//time, lat, long, alt
0,-116.52,35.02,80,
300,-116.52,35.04,4000,
600,-116.52,35.08,9000,
900,-116.52,35.02,3000,
1100,-116.52,35.02,1000,
1400,-116.52,35.02,100
]
}