Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5940719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:00:28+00:00 2026-05-22T16:00:28+00:00

I’m using the Core Data Framework to manage a set of accounts which also

  • 0

I’m using the Core Data Framework to manage a set of accounts which also include geospatial (GPS) coordinate data for each account. How can I query against this data based on position of the device to get a list of accounts within x feet and list them in order of distance?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:00:29+00:00Added an answer on May 22, 2026 at 4:00 pm

    to get you started, here’s a method i use in my iOS app that returns the distance in meters between two CLLocationCoordinate2D locations, assuming the Google Spherical Mercator Projection (if you want to use another projection, you can specify the appropriate flattening ratio value (f) and semi-major axis value (a). if you want the forward and backward azimuth values between the coordinates, you can uncomment and return the faz and baz values along with the distance by defining your own struct. this method can be used to add the distance to each of your ‘account’ objects and the current location being reported by your CLLocationManager object, then you could easily sort and filter an array of account objects based on their distances.

    based on code by Gerald Evenden located here: http://article.gmane.org/gmane.comp.gis.proj-4.devel/3478

    #define PI 3.141592653589793238462643
    #define EPS 5e-14
    #define DEG_TO_RAD 0.0174532925199432958
    
    // returns the geodesic distance in meters between two coordinates based on the google spherical mercator projection.
    - (int) geodesicDistanceFromCoordinate: (CLLocationCoordinate2D) fromCoord toCoordinate: (CLLocationCoordinate2D) toCoord {
        double c, d, e, r, x, y, sa, cx, cy, cz, sx, sy, c2a, cu1, cu2, su1, tu1, tu2, ts, phi1, lam1, phi2, lam2, f, baz, faz, s, a;
    
        phi1 = fromCoord.latitude * DEG_TO_RAD;
        lam1 = fromCoord.longitude * DEG_TO_RAD;
        phi2 = toCoord.latitude * DEG_TO_RAD;
        lam2 = toCoord.longitude * DEG_TO_RAD;
        f = 0;  //google's spherical mercator projection has no flattening
        a = 6378137;  //earth's axis in meters used in google's projection
    
        r = 1. - f;
        tu1 = r * tan(phi1);
        tu2 = r * tan(phi2);
        cu1 = 1. / sqrt(tu1 * tu1 + 1.);
        su1 = cu1 * tu1;
        cu2 = 1. / sqrt(tu2 * tu2 + 1.);
        ts = cu1 * cu2;
        baz = ts * tu2;
        faz = baz * tu1;
        x = lam2 - lam1;
    
        do {
            sx = sin(x);
            cx = cos(x);
            tu1 = cu2 * sx;
            tu2 = baz - su1 * cu2 * cx;
            sy = sqrt(tu1 * tu1 + tu2 * tu2);
            cy = ts * cx + faz;
            y = atan2(sy, cy);
            sa = ts * sx / sy;
            c2a = -sa * sa + 1.;
            cz = faz + faz;
            if (c2a > 0.)
                cz = -cz / c2a + cy;
            e = cz * cz * 2. - 1.;
            c = ((c2a * -3. + 4.) * f + 4.) * c2a * f / 16.;
            d = x;
            x = ((e * cy * c + cz) * sy * c + y) * sa;
            x = (1. - c) * x * f + lam2 - lam1;
        } while (fabs(d - x) > EPS);
    
    //forward azimuth    faz = atan2(tu1, tu2);
    //backward azimuth    baz = atan2(cu1 * sx, baz * cx - su1 * cu2) + PI;
        x = sqrt((1. / r / r - 1.) * c2a + 1.) + 1.;
        x = (x - 2.) / x;
        c = (x * x / 4. + 1.) / (1. - x);
        d = (x * .375 * x - 1.) * x;
        s = ((((sy * sy * 4. - 3.) * (1. - e - e) * cz * d / 6. - e * cy) * d / 4. + cz) * sy * d + y) * c * r;
        return (int)(s * a);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
In order to apply a triggered animation to all ToolTip s in my app,
I want use html5's new tag to play a wav file (currently only supported
I want to count how many characters a certain string has in PHP, but
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.