How to know a Point belong to a Area of the Layer?!

hungqnx
hungqnx Global Mapper User
edited October 2008 in Technical Support
I don't know what function use to check a Point belong to a Area of the Layer?
Can u help me?!
Thank!

Comments

  • global_mapper
    global_mapper Administrator
    edited October 2008
    Are you referring to doing this using the SDK? There is not currently a function in the SDK to test a point to see if it is in an area feature, but there well known algorithms that a quick Google search should turn up for doing a point-in-polygon operation. I can point you at one if you need one.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • hungqnx
    hungqnx Global Mapper User
    edited October 2008
    Could u tell me that algorithms?
    Thanks!
  • global_mapper
    global_mapper Administrator
    edited October 2008
    Here is some simple C code with the algorithm from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html:

    int i, j, c = 0;
    for (i = 0, j = nvert-1; i < nvert; j = i++) {
    if ( ((verty>testy) != (verty[j]>testy)) &&
    (testx < (vertx[j]-vertx) * (testy-verty) / (verty[j]-verty) + vertx) )
    c = !c;
    }
    return c;
    }