{ "id": "99630", "key": "TIMOB-10782", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2012-08-22T16:32:39.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [ "api" ], "versions": [ { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" } ], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:03:33.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "Implement a native Haversine function in ObjC or Java for better performance, allowing developers willing to implement Geolocation with distance calculations (which most do) usage to a more efficient and fast Haversine implementation.\r\n\r\nWe could map against something like:\r\n\r\n{code}\r\nTi.Geolocation.haversine({lat1: xxx, long1:xxx, lat2: xxx, long2: xxx, unit: 'metric'})\r\n{code}\r\n\r\n\r\nfor calculating the distance between two points in the sphere.\r\n\r\nThere are implementation examples of the Haversine formula here:\r\n\r\nhttp://www.movable-type.co.uk/scripts/latlong.html\r\n\r\non the wikipedia there are examples in several computer languages:\r\n\r\nhttp://en.wikipedia.org/wiki/Haversine_formula\r\n\r\n\r\nAlso, there is a formula called Vincentys which is way more precise (millimetric precision) but also consumes more CPU due to the fact that it considers the real shape of the earth while Haversine considers the earth as a regular sphere (thus having an acceptable error margin).\r\n\r\nwe could also made something like *Ti.Geolocation.vincenty()* for more precise stuff.\r\n\r\nFollows Vincenty's Formula explanations:\r\n\r\nhttp://www.movable-type.co.uk/scripts/latlong-vincenty.html\r\nhttp://en.wikipedia.org/wiki/Vincenty%27s_formulae\r\n\r\n\r\n------\r\n\r\n\r\nApart all of that we should really have a native SQL haversine formula for users that store latitude and longitude data in SQLite Databases.\r\n\r\n\r\nSo we could make queries like:\r\n\r\n*SELECT * FROM Locations ORDER BY distance(Latitude, Longitude, 51.503357, -0.1199)*\r\n\r\n\r\nThere are ways of implementing custom functions inside the SQLite database, at least on ObjC, thus allowing for Geodesic queries inside the DB...\r\n\r\nTake a look at this Obj-C + SQLite implementation:\r\n\r\nhttp://www.thismuchiknow.co.uk/?p=71\r\n\r\n\r\n", "attachment": [], "flagged": false, "summary": "iOS: Native Haversine formula for calculating distances inside Ti.Geolocation and Ti.Database", "creator": { "name": "ygbr", "key": "ygbr", "displayName": "Ygor Lemos", "active": true, "timeZone": "America/Sao_Paulo" }, "subtasks": [], "reporter": { "name": "ygbr", "key": "ygbr", "displayName": "Ygor Lemos", "active": true, "timeZone": "America/Sao_Paulo" }, "environment": "iOS, Android", "comment": { "comments": [ { "id": "216133", "author": { "name": "ygbr", "key": "ygbr", "displayName": "Ygor Lemos", "active": true, "timeZone": "America/Sao_Paulo" }, "body": "More on the SQLite native functions:\r\nhttp://souptonuts.sourceforge.net/readme_sqlite_tutorial.html", "updateAuthor": { "name": "ygbr", "key": "ygbr", "displayName": "Ygor Lemos", "active": true, "timeZone": "America/Sao_Paulo" }, "created": "2012-08-25T15:07:04.000+0000", "updated": "2012-08-25T15:07:04.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }