Autocad ObjectARX class AcDbGeoPositionMarker coordinate translation - location

How class AcDbGeoPositionMarker translate x,y,z coordinats to lat,lon,elv and vice versa?

Use the latLonAlt method in the AcDbGeoPositionMarker class to get lat, lon and alt. setLatLonAlt to set the objects lat, lon and alt. geoPosition to get a X, Y and Z coordinates (a AcGePoint3d object with coordinates as properties).
Link to docs: http://docs.autodesk.com/ACDMAC/2015/ENU/Mac_Lightsaber_Dev_Help/Reference_machtml/index.html?frmname=topic&frmfile=AcDbGeoPositionMarker__AcDbGeoPositionMarker.html

Related

How to Convert United States State Plane coordinates to Latitude and Longitude in Mathematica?

How to Convert United States State Plane coordinates to Latitude and Longitude in Mathematica?
I'm converting Washington DC Northing and Easting (in feet) of a location to latitude and longitude
Here is the address:
316 PENNSYLVANIA AVENUE SE 20003
And here are the coordinate:
X= 399901.19 Y= 135465.63
I know that I should be ND83 and my SPC Zone is MD-1900
I checked GeodesyData[] and I tried all these:
"NAD27", "NAD831986", "NAD83CORS93", "NAD83CORS94", "NAD83CORS96", \
"NAD83HARN"
with GeoPosition[{399901, 135465, 0}, datum] but with no success. I know in R I can use epsg:2804 or epsg:3559 but in Mathematica, I don't know which code to use, and none of these worked.
I found out how to answer it:
Our coordinates are in datum NAD83 for Maryland 1800. Therefore, our datum string for Mathematica should be "SPCS83MD00"
Knowing the State and the code connected to to the state are crucial to build the datum string. After SPCS83, one adds the state, in this case MD, and the last 2 digits of the four-digit code.
Hence, one can convert to (WGS84) or latitude and longitude as follows:
LatitudeLongitude[GeoGridPosition[{399901., 135466.}, "SPCS83MD00"]]
One more thing:
If you want to find out the extension for SPCS83 or NAD 83 in Mathematica you just need to use, and start typing SPCS83 or NAD83 and it will give you the possible string containing the state and its codes (some states have more than 1 code)
GeoProjectionData["SPCS83MD00"]

Unable to get the location bound of Sketchup model using Sketchup Ruby API

I have a Sketchup 3d model that is geo-located. I can get the geo-location of the model as follows :-
latitude = Sketchup.active_model.attribute_dictionaries["GeoReference"]["Latitude"]
longitude = Sketchup.active_model.attribute_dictionaries["GeoReference"]["Longitude"]
Now i want to render this model on a 3D globe. So i need the location bounds of the 3d model.
Basically i need bounding box of the model on 2d map.
Right now i am extracting the same from the corners of a model(8 corner).
// This will return left-front-bottom corner.
lowerCorner = Sketchup.active_model.bounds.corner(0)
// This will return right-back-top corner.
upperCorner = Skectup.active_model.bounds.corner(6)
But it returns simple geometrical points in meters, inches depending upon the model.
For example i uploaded this model in sketchup. Following are the values of geo-location, lowerCorner and upperCorner respectively that i'm getting by using the above code for the above model.
geoLocation : 25.141407985864, 55.18563969191 //lat,long
lowerCorner : (-9483.01089", -6412.376053", -162.609524") // In inches
upperCorner : (-9483.01089", 6479.387909", 12882.651999") // In inches
So my first question is what i'm doing is correct or not ?
Second question is If yes for the first how can i get the values of lowerCorner and upperCorner in lat long format.
But it returns simple geometrical points in meters, inches depending upon the model.
Geom::BoundingBox.corner returns a Geom::Point3d. The x, y and z members of that is a Length. That is always returning the internal value of SketchUp which is inches.
However, when you use Length.to_s it will use the current model's unit settings and format the values into that. When you call Geom::Point3d.to_s it will use Length.to_s. On the other hand, if you call Geom::Point3d.inspect it will print the internal units (inches) without formatting.
Instead of tapping into the attributes of the model directly like that I recommend you use the API methods of geo-location: Sketchup::Model.georeferenced?
By the sound of it you might find Sketchup::Model.point_to_latlong useful.
Example - I geolocated a SketchUp model to the town square of Trondheim, Norway (Geolocation: 63°25′47″N 10°23′36″E):
model = Sketchup.active_model
bounds = model.bounds
# Get the base of the boundingbox. No need to get the top - as the
# result doesn't contain altiture information.
(0..3).each { |i|
pt = bounds.corner(i)
latlong = model.point_to_latlong(pt)
latitude = latlong.x.to_f
longitude = latlong.y.to_f
puts "#{pt.inspect} => #{longitude}, #{latitude}"
}

MKMapView is misaligned to its region property

I want to display a certain map region in MKMapView but when I put a rectangular overlay on the map with the very same parameters it is displayed misaligned vertically. It looks good enough close to the equator but the misalignment is increasing with the latitude and the span.
This is for a mac app, but it should be the same for iOS.
This is my relevant code:
MKCoordinateRegion mapRegion = MKCoordinateRegionMake(CLLocationCoordinate2DMake(latCenter, lonCenter), MKCoordinateSpanMake(mapWidthY, mapWidthX));
self.radarMap.region = mapRegion;
CLLocationCoordinate2D coordinates[4];
coordinates[0] = CLLocationCoordinate2DMake(latCenter+mapWidthY/2, lonCenter+mapWidthX/2);
coordinates[1] = CLLocationCoordinate2DMake(latCenter+mapWidthY/2, lonCenter-mapWidthX/2);
coordinates[2] = CLLocationCoordinate2DMake(latCenter-mapWidthY/2, lonCenter-mapWidthX/2);
coordinates[3] = CLLocationCoordinate2DMake(latCenter-mapWidthY/2, lonCenter+mapWidthX/2);
self.boundaryOverlay = [MKPolygon polygonWithCoordinates:coordinates count:4];
[self.radarMap addOverlay:self.boundaryOverlay];
It shows this: (Notice the blue rect overlay is moved up so the upper region is not displayed):
Instead of something like this: (I'm aware of that it is displayed in aspect fill):
When you set the region property of an MKMapView object, MapKit adjusts the value of the region property so that it matches the actual region that's visible. That means that the actual value of region isn't going to be exactly what you assigned to it. So instead of creating the polygon using the region that you assigned to the map, you should get the updated value of region from the MKMapView object and use that to create the polygon.
MKCoordinateRegion mapRegion = MKCoordinateRegionMake(CLLocationCoordinate2DMake(latCenter, lonCenter), MKCoordinateSpanMake(mapWidthY, mapWidthX));
self.radarMap.region = mapRegion;
CLLocationCoordinate2D coordinates[4];
// Get the actual region that MapKit is using
MKCoordinateRegion actualMapRegion = self.radarMap.region;
CLLocationDegrees actualLatCenter = actualMapRegion.center.latitude;
CLLocationDegrees actualLonCenter = actualMapRegion.center.longitude;
CLLocationDegrees actualLatSpan = actualMapRegion.span.latitudeDelta;
CLLocationDegrees actualLonSpan = actualMapRegion.span.longitudeDelta;
// And use that to create the polygon
coordinates[0] = CLLocationCoordinate2DMake(actualLatCenter+ actualLatSpan/2, actualLonCenter+ actualLonSpan/2);
coordinates[1] = CLLocationCoordinate2DMake(actualLatCenter+ actualLatSpan/2, actualLonCenter-actualLonSpan/2);
coordinates[2] = CLLocationCoordinate2DMake(actualLatCenter-actualLatSpan/2, actualLonCenter-actualLonSpan/2);
coordinates[3] = CLLocationCoordinate2DMake(actualLatCenter-actualLatSpan/2, actualLonCenter+ actualLonSpan/2);
self.boundaryOverlay = [MKPolygon polygonWithCoordinates:coordinates count:4];
[self.radarMap addOverlay:self.boundaryOverlay];
I was curious about the increasing misalignment that you were seeing as you moved north. It occurred to me that you were probably using a fixed ratio for the mapWidthX and mapWidthY. MapKit uses a projection that is non-conformal. One consequence of that is that the map gets stretched in the North-South direction, with more stretching the farther you get from the equator.
If you create your region using a ratio that's correct for the equator, it will be incorrect as you move toward the poles. MKMapView will take the region you give it and display something close to it. But the farther you get from the equator, the more of an adjustment it needs to make. And the bigger the difference between the region you give it and the actual region it uses.

Animate cclayergradient colors

Is there a way to animate the colors of a CCLayerGradient over time?
I'm thinking of some CC*** function like CCBezierTo...
Is there something to animate arbitrary values of an object?
Use CCActionTween for this. It allows you to change the value of a property over time by providing the property's name.
Only works with integral data types such as int, float but not structs such as CGPoint, CGRect. But it's easy enough to create a category with (for example) positionX and positionY properties which update the corresponding x/y value of a CGPoint property.

How to zoom to fit in WP7 Bing Maps control using LocationCollection?

How can I zoom the Microsoft.Phone.Controls.Maps.Map control to the correct zoom level on Windows Phone 7?
I have a LocationCollection of GeoCoordinates and I calculated the Center myself, but now how do I calculate the correct zoom level to fit the LocationCollection?
P.S. Is there an out of the box method to calculate the center of GeoCoordinates so I don't have to calculate it myself?
EDIT:
I've found another fine solution: http://4mkmobile.com/2010/09/quick-tip-position-a-map-based-on-a-collection-of-pushpins/
map.SetView(LocationRect.CreateLocationRect(points));
You can use the following code to calculate the LocationRect that bounds a set of points, and then pass the LocationRect to the SetView() method on the map control:
var bounds = new LocationRect(
points.Max((p) => p.Latitude),
points.Min((p) => p.Longitude),
points.Min((p) => p.Latitude),
points.Max((p) => p.Longitude));
map.SetView(bounds);
The map control handles animating from the current position to the new location.
NOTE: You'll need a using statement for System.Linq to get the Min and Max methods.
Derek has already given the answer so you should accept his, I offer an alternative code for cases where there many points. This approach only iterates the points collection once instead 4 times however it isn't as asthetically pleasing.
double north, west, south, west;
north = south = points[0].Latitude;
west = east = points[0].Longitude;
foreach (var p in points.Skip(1))
{
if (north < p.Latitude) north = p.Latitude;
if (west > p.Longitude) west = p.Longitude;
if (south > p.Latitude) south = p.Latitude;
if (east < p.Longitude) east = p.Longitude
}
map.SetView(new LocationRect(north, west, south, east));
As suggested by the other answers I use SetView with a LocationRect.
However I found that it always produces to low zoom level, since only integer values was used. If for instance the perfect zoom level would be 5.5, you would get 5.0. To get a proper fit I calculate a new zoom level from TargetZoomLeveland TargetBoundingRectangle:
viewRect = LocationRect.CreateLocationRect(coordinates);
map.SetView(viewRect);
double scale = map.TargetBoundingRectangle.Height/viewRect.Height;
map.ZoomLevel = map.TargetZoomLevel + Math.Log(scale, 2);
This example sets the zoom level to fit viewRect's height on the screen.

Resources