List<List<List<Float>>> Parse though polygon object - android-studio

I am trying to parse through a Polygon object to get each of the latitude and longitude but having trouble iterating though it. I am developing in Kotlin Android Studio IDE.
[
[
[-119.81009614166666, 39.52721586111111],
[-119.81022475833333, 39.527206336111114],
[-119.81007891388889, 39.52602547777778],
[-119.8099503, 39.526035005555556],
[-119.81009614166666, 39.52721586111111]
]
]

If your coordinates is in the format above, do the following steps:
var firstCoord = coordinates[0][0]
Log.i("firstCoord", firstCoord.toString());
Log statement gives you the first coordinates: [-119.8101, 39.527214]
Not to sure why some of the precision is lost.

Related

In GeoDMS, how can I transform string coordinates to dpoint?

I have problems converting coordinates in string format to dpoint format in GeoDMS GUI version 7.177.
I'm trying to read the BAG (basisadministratie gemeenten, Dutch municipality administration, a giant geo file) into GeoDMS directly from the Kadaster. It's first been converted from .xml into .csv, then the shapes of the buildings have been transformed in a format seemingly the same as the Vesta format, e.g.:
{5:{249943.307,593511.272}{249948.555,593512.791}{249946.234,593520.809}{249940.987,593519.29}{249943.307,593511.272}}
I am able to read the transformed CSV file into GeoDMS, then also able to write it as strings to .dmsdata format for speed and load it from there into GeoDMS again. However, when wanting to transform the strings into coordinates, I get the error
DPoint Error: Cannot find operator for these arguments:
arg1 of type DataItem<String>
Possible cause: argument type mismatch. Check the types of the used arguments.
My GeoDMS code looks like
unit<uint32> altBag:
storageName = 'c:/zandbak/output/bagPND.fss'
, storageReadOnly = 'true'
, dialogType = 'map'
, dialogData = 'geometry'
{
attribute <string> pandGeometrie; // works and looks good
attribute <dpoint> geometry := dpoint(pandGeometrie); // doesn't work, error above
attribute <rdc> geometry2 := pandGeometrie[rdc]; // doesn't work either
}
Is there a way to do this? Or is string to dpoint (or another type of point) unsupported and should I transform the CSV to shape file first?
you can try this:
attribute<dpoint> Geometry(poly) := dpolygon(GeometryStr);
and if a specific projection is required:
attribute<rdc_meter> Geometry2(poly) := value(GeometryStr, rdc_meter);

Last vertex in vertex buffer not being set

I'm attempting to render a sphere in Direct11 using SharpDX. I have correctly read in the OBJ model, created the vertex buffers, and set the buffers on the context for rendering.
My problem is that everything rendering perfectly EXCEPT the very last vertex, which is rendered as if it were at 0, 0, 0. Below is a screen shot of this:
I have checked the vectors that get used when creating the buffers and there is no missing data in there, I even changed the last element in the array like this:
vertexBufferArray[vertexBufferArray.Length - 1].X = 1.0f;
and had no result. Whereas if I change the second to last element like this:
vertexBufferArray[vertexBufferArray.Length - 2].X = 1.0f;
I get this result:
The vertex count that I am passing to the render call is correct because if I pass it VertexCount - 1, I don't get the last triangle at all, and if I pass it VertexCount + 100, nothing changes at all.
Any ideas?
As usual I end up fixing the problem 10 mins after I make a big post about it.
The problem was my Input Assembler, my input elements for POSITION and NORMAL were of Format.R32G32B32A32_Float, when they should have been Format.R32G32B32_Float since I was giving my vertices in as Vector3s.

mongodb, finding by coordinate + query

I'm building a web application over Node.js and MongoDB which is based on geolocated points.
The document is something like this:
{ name: ""
keywords: [Array of strings]
location: {lng: double, lat: double }
}
I am wondering how could I use find() to find documents that are near from a coordinate but, in addition, are coincident with any of he keywords in the keywords array.
Imagine that keywords are: ["restaurant", "bar", "coffee"]
I've looked into 2d Index, but the secondary index must be a string. It can't be an array of strings.
The problem is that a document could have more than one keyword (or category) so I can't use a simple string to query them
How would you implement this?
Thanks!
What version of mongo? It looks like this was added in 2.4.0: SERVER-8457

Why am I getting an array of NANs when trying to plot a map with D3.js?

I am tring to plot a map with d3.js using GeoJSON, but the paths generated look like this:
<path d="MNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,‌​NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,N‌​aNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,Na‌​NLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaN‌​LNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNL‌​NaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLN‌​aN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNZ">
the code and data are in this Gist:
https://gist.github.com/4157853
I can load the data just fine on QGIS.
Does any one know what is causing this?
The way you have specified the offset in the Mercator projection doesn't seem right. The projection.translate method expects a two element array:
https://github.com/mbostock/d3/wiki/Geo-Projections#wiki-mercator_translate
So instead of:
proj.translate(-43.8,-23.2).scale(10);
you would need to say:
proj.translate([-43.8,-23.2]).scale(10);
-- edit --
See source of projection.translate: https://github.com/mbostock/d3/blob/3.0/src/geo/projection.js#L139
projection.translate = function(_) {
if (!arguments.length) return [x, y];
x = +_[0];
y = +_[1];
return reset();
};
If the argument _ is not an array then +_[0] will return a NaN and therefore the x and y will become NaNs. (This is because trying to get one element from a number (e.g. 213[0]) returns undefined and casting undefined to a number (e.g. +undefined) yields NaN.)
If the code you posted in the gist is everything you're trying to run, then the data you show in data.json is not being loaded anywhere. Anyway, your draw function is acting on the data defined by the variable map (line 16), which refers to a simulation variable which isn't set anywhere. And even if it did, line 34 then refers to a features property of the object passed in as json, which map does not have.
In summary, you need to pass the JSON you posted in the gist to your draw function. Then it might well work. If you don't pass in valid data to the d3 SVG helpers, you'll get a bunch of NaN out.

MKMetersBetweenMapPoints incorrectly returning distance in meters

running this code:
NSLog(#"%f", MKMetersBetweenMapPoints(MKMapPointMake(33.6523, -118.507), MKMapPointMake(34.516, -117.628)));
returns this:
0.015819
When the expected output should be ~136900. What am I doing wrong?
It looks like you're giving a regular latitude and longitude to MKMapPointMake(). An MKMapPoint contains and x and y value, not latitude and longitude.
Use MKMapPointForCoordinate(myLocation) to convert your locations to map points, then give those to your MKMetersBetweenMapPoints() function.
Or easier still, use -distanceFromLocation: with two CLLocation objects. It gives you back a distance in meters, taking into account the curvature of the earth.

Resources