coordinates

Finding coordinates of a character?

拜拜、爱过 提交于 2019-12-04 17:49:15
I have a multi-line TextView . Is there a way to get the x coordinate of the pixel to the left of a character e.g. the 3rd character? In my case it will always be the 3rd character, but a general solution would be nicer. I have the y coordinate of the pixel just above the character using: Layout textViewLay = mTextView.getLayout(); int posY = textViewLay.getLineTop(0); but the x coordinate has me stumped. Any ideas? I'm probably missing something really simple. Try to use this code: Rect bounds = new Rect(); Paint tpaint = textView.getPaint(); tpaint.getTextBounds(text,0,2,bounds); int height

Generating pixel values of line connecting 2 points

旧时模样 提交于 2019-12-04 16:41:26
I am having some troubles trying to connect separate points in my picture (see below). Right now, the code I have is as follows: first_time = resulting_coords[0:40] for i in range(len(first_time)): if(i < (len(first_time))-1): cv2.line(copy_test_image[0], (resulting_coords[i,0],resulting_coords[i,1]), (resulting_coords[i+1,0],resulting_coords[i+1,1]), (0,0,225), 2) elif(i>=(len(first_time))-1): # print(i) cv2.line(copy_test_image[0], (resulting_coords[i,0],resulting_coords[i,1]), (resulting_coords[0,0],resulting_coords[0,1]), (0,0,225), 2) Which actually gives the result I want: Results in But

Figuring out distance and course between two coordinates

我与影子孤独终老i 提交于 2019-12-04 14:49:21
I have 2 coordinates and would like to do something seemingly straightforward. I want to figure out, given: 1) Coordinate A 2) Course provided by Core Location 3) Coordinate B the following: 1) Distance between A and B (can currently be done using distanceFromLocation) so ok on that one. 2) The course that should be taken to get from A to B (different from course currently traveling) Is there a simple way to accomplish this, any third party or built in API? Apple doesn't seem to provide this but I could be wrong. Thanks, ~Arash EDIT: Thanks for the fast responses, I believe there may have been

Android: Find absolute click position on the ImageView after zooming (using pinch to zoom using Matrix Layout)

岁酱吖の 提交于 2019-12-04 14:11:37
问题 I am using code found in Hello Android, 3rd Edition for Pinch to Zoom functionality. After using this the pinch to zoom works fine, but after zooming i want to get the absolute click position on the image view. Here is my code package org.example.touch; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.Matrix; import android.graphics.PointF; import android.os.Bundle; import android.util.FloatMath; import android.util.Log; import android.view.MotionEvent;

How to find point related to set of coordinates?

醉酒当歌 提交于 2019-12-04 14:06:54
问题 I have a set of about 5000 geographical (WGS84) coordinates. All of them are inside 40km square. Is there any algorithm / R function to find point, inside square and not in the given set, farthest from any point from set? I mean how to find point in the square where the distance to the nearest point from set is longest ? Now I do it by generating grid of coordinates equally spaced and finding distance from each grid point to the nearest set point. Is there any less numerical / not brute force

Find Coordinates for point on screen?

非 Y 不嫁゛ 提交于 2019-12-04 14:04:48
The thing is I have some graphics shown in a form, rectangle for example, and I want to capture when the point gets over thees fields. So I Thoght I try to find the corrrdinates for thees rectangles, but as thay are the coords in the form it dose not match the ones with the mouse location. So I wonder is there a way to find what coord on the screen a Point has on the screen and not in the form or controller? Each control hs PointToFoo methods for conversion. Note that you should call this from the parent of the object who's location you want: Point scrPos = this.PointToScreen(panel1.Location);

What event is fired when MKMAPVIEW extent changes

橙三吉。 提交于 2019-12-04 13:55:55
问题 What event is fired when the MKMAPVIEW changes extent (zooms in or out, panning)? I need to get the coordinates that are used to display the map. 回答1: You should adopt the MKMapViewDelegate protocol and implement mapView:regionDidChangeAnimated: method which will be called in the event the region changes. However since it will be called many times when scrolling you should take that into consideration before implementing that method. Getting the Top-Left coordinate of the map

Fastest way to determine COUNTRY from millions of GPS coordinates [R]

丶灬走出姿态 提交于 2019-12-04 13:45:50
I have millions of GPS coordinates and want to quickly add a column of the country of the coordinates. My current method works but is extremely slow: library(data.table) #REPRODUCE DATA data <- data.table(latitude=sample(seq(47,52,by=0.001), 1000000, replace = TRUE), longitude=sample(seq(8,23,by=0.001), 1000000, replace = TRUE)) #REQUIRED PACKAGES if (!require("sp")) install.packages("sp") if (!require("rworldmap")) install.packages("rworldmap") if (!require("sf")) install.packages("sf") library(sp) library(rworldmap) library(sf) #CURRENT SLOW FUNCTION coords2country = function(points,latcol

canvas get points on mouse events

非 Y 不嫁゛ 提交于 2019-12-04 12:54:58
I am having the following function to get the mouse click positions(coordinates). $('#myCanvas').on('click', function(e) { event = e; event = event || window.event; var canvas = document.getElementById('myCanvas'), x = event.pageX - canvas.offsetLeft, y = event.pageY - canvas.offsetTop; alert(x + ' ' + y); }); I need to get the mouse point on clicking a position and also secound mouse point position after draging the same. ie., mousedown point and mouseup points. Try a little different setup: var canvas = myCanvas; //store canvas outside event loop var isDown = false; //flag we use to keep