How to find the BBOX coordinates of a jvectormap - latitude-longitude

I have the SVG file of a particular state, I have successfully converted the svg coordinates into a jvectormap, but I dont know how to identify the bbox coordinates of the projected region, can any one help me to identify it ?

Assuming your map has been instanced in my_map, get a map reference:
var mapObj = $('#my_map').vectorMap('get', 'mapObject');
You can get the bbox of a region in following way:
onRegionOver: function(evt, code){
var bb = mapObj.regions[code].element.shape.getBBox();
console.log(bb);
}
You will get for example:
SVGRect
height:88.74008178710938
width:99.780029296875
x:705.31005859375
y:312.38995361328125
Is this what you need?

Related

Polyline drawn is showing below buildings

The polyline is drawn showing below building.
(source: gifyu.com)
How can I get the polyline top of all layers
please suggest
adding polyline as
var coordinates = locationsArrToAdd.map({ (location: CLLocation!) -> CLLocationCoordinate2D in
return location.coordinate
})
let polyline = MKPolyline(coordinates: &coordinates, count: locationsArrToAdd.count)
self.mapView.addOverlays([polyline], level: .aboveLabels)
According to Apple, the highest available level you can add an overlay to is the MKOverlayLevel.aboveOverlays constant you are currently using. However, their documentation states that this will:
Place the overlay above map labels, shields, or point-of-interest icons but below annotations and 3D projections of buildings.
From what I can see, the best solution is to disabled buildings in 3D mode, so that your polylines are visible:
self.mapView.showsBuildings = false

Convert Vision face detection VNFaceLandmarkRegion2D points into frame coordinates to be scale

I'm using vision framework to detect face landmark and it's working fine but i need to transform the face landmarks like nose, eyes and for that i need to get nose, eyes position in frame coordinate as face landmark is drawing using VNFaceLandmarkRegion2D points.
Please let me know how to convert VNFaceLandmarkRegion2D points to frame coordinate. So i can get the location in view for transformation or suggest any other way to to transform face landmark.
This code from Joshua Newnham solves your problem.
func getTransformedPoints(
landmark:VNFaceLandmarkRegion2D,
faceRect:CGRect,
imageSize:CGSize) -> [CGPoint]{
// last point is 0.0
return landmark.normalizedPoints.map({ (np) -> CGPoint in
return CGPoint(
x: faceRect.origin.x + np.x * faceRect.size.width,
y: imageSize.height - (np.y * faceRect.size.height + faceRect.origin.y))
})
}
As a newbie this is what I could find to get face marks as a CGPoint:
First converted the selected image to CIImage
Used faceDetector on the image
Parsed the image for each face in case it has more than one
Code:
let chosenPicture = CIImage(data: (self.selectedimage.image?.tiffRepresentation)!)
let selectedFace = faceDetector?.features(in: chosenPicture!, options: [CIDetectorSmile:true])
for person in selectedFace as! [CIFaceFeature] {
let p1LeftEye = person.leftEyePosition
let p1RightEye = person.rightEyePosition
let p1Mouth = person.mouthPosition

How to crop rect area of PDF page using pdf.js

I want to crop specific rect (x,y,width,height) of a PDF page. Is that possible with pdf.js?
Get the canvas reference of the page. Let us say your current scale is 133% so you need to multiply your coordinates by 1.33
var context = document.getElementById("page1").getContext('2d');
var imageData = context.getImageData(
160.89*(1.33),
193.97*(1.33),
517.29*(1.33),
148.87*(1.33))
Then you can put it to some other canvas or do something with it
context.putImageData(imageData,0,0);

Isn't there an "auto disposition" method?

I have a graph with nodes and edges and I want to display them.
Isn't there any function which, given this graph, displays it without me to give exact coordinates?
yes, you can use the auto layout
http://jgraph.github.io/mxgraph/docs/js-api/files/layout/mxCompactTreeLayout-js.html
this url construct a compact tree layout.
var layoutMgr = new mxLayoutManager(graph);
layoutMgr.getLayout = function(cell) {
return layout;
};

Projection issue with ESRI JSAPI and ArcGIS map service

I was trying to obtain a gpx file with some coordinates by drawing on an Openlayers map with an ArcGIS baseMap.
When I draw the polyline and create the gpx, if I open it on Google Earth, what I see is not what I drawed before, the line is totally different from the original and not positioned where I drawed it.
I know it's a projection problem, I've tried trasforming the geometry object from Mercator to Geographic, also getting directly the geographic coordinates from the map coordinates, but nothing.
I tried to set "spatialReference" to 4362 and then to 3857, but nothing changes.
I'm going to use that .gpx on a gps device (the next week I'll go to the Svalbard islands and I need some gps tracks to go around Longyearbyen by snowmobile, there there aren't any sign of life out the town, so I must be prepared to it), when I'll be there I'll adjust the output right for the device they will rent to me, but now I need to save on the .gpx file almost the right coordinates.
I'm getting from the map those coordinates:
lat: 61.22582068741976
lon: 4.684820015391338
when I'm expecting instead something around 78. lat and 15. lon.
This is some of the code I use to create the map (I'm not pasting the code I know it's not responsible of my problems):
var initialExtent = new esri.geometry.Extent({"xmin":505615.5801124362,"ymin":8678955.717187276,"xmax":525935.6207525175,"ymax":8689168.654279819,"spatialReference":{"wkid":32633,"latestWkid":32633}});
map = map = new esri.Map("map", {extent: initialExtent, logo : false});
basemapURL = "http://geodata.npolar.no/ArcGIS/rest/services/inspire1/NP_TopoSvalbard_U33_CHL/MapServer/";
map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer(basemapURL));
Here I'm using wkid 32633 that is the default for that map, tried to change with known ones, but nothing happened.
And now the code I use to get the coordinates:
dojo.connect(tb, "onDrawEnd", getCoords);
function getCoords(geo) {
var r=confirm("Salvare tracciato?");
if (r==true) {
geo = esri.geometry.webMercatorToGeographic(geo);
for ( var path = 0; path < geo.paths.length; path ++ ) {
for ( var pt = 0; pt < geo.paths[path].length; pt++ ) {
tra += '<wpt lat="'+geo.paths[path][pt][1]+'" lon="'+geo.paths[path][pt][0]+'"></wpt>';
}
}
}
}
"tra" is a variable that stores all the code I'll insert into the gpx file with an other function.
The "webMercatorToGeographic" function transform the map coordinates to geographic ones.
Thanks to Devdatta Tengshe on GIS.stackexchange I got what I need:
Use the proj4js library in your application. To do this, follow these
steps:
Download the latest library from
https://github.com/proj4js/proj4js/releases In your HTML file use
You'll
need to define the projections before you can use it. You can do this
by using the following lines of code: var UTM33N= "+proj=utm +zone=33
+ellps=WGS84 +datum=WGS84 +units=m +no_defs"; var GCS84="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
When you need to transform, you can use the following line: var
transformed=proj4(UTM33N,GCS84,[x,y]); where x & y are the coordinates
in your given projection. As output you'll get an array with two
elements, the longitude, & the Latitude
That worked fine.