letsdoitworld / World-Cleanup-Day

☀️ World Cleanup Day: App (React Native) & Platform (Node). Join us in building software for a cleaner planet! PRs welcome!
https://www.letsdoitworld.org/
GNU General Public License v3.0
109 stars 45 forks source link

How to handle adding trashpoints in prohibited areas? #75

Open krishaamer opened 7 years ago

lynxlynxlynx commented 7 years ago

prohibited in what sense?

KristiinaKerge commented 7 years ago

prohibited areas - dangerous for mappers, private property

KristiinaKerge commented 6 years ago

is it something that CARTO experts can help us to solve? @jaakla do they have this kind of data

jaakla commented 6 years ago

What do you mean by 'handle' here? You can define some areas as prohibited areas, and then correlate geographically (overlay) them with trash points, to see whether a trash point is inside of some; if this is what you mean. The big challenge seems to be to have data of prohibited areas, it is too specific (subjective) to find readymade data from anywhere, unless you narrow the definition quite specifically: e.g. 'military regions' or 'closed to public areas' which are mapped in openstreetmap, I'd guess this covers just small % of areas what you mean here. The best method would be manually creating own map layer for these areas, which may be a challenge organisationally and technically. Technically from mapping point of view it should be finally stored as new carto.com polygon dataset, and then carto enables easy calculation of overlaps.

KristiinaKerge commented 6 years ago

I meant to show on the map areas that the users should avoid during mapping events

lynxlynxlynx commented 6 years ago

What kind of a shitty prohibited area is it, if it doesn't have a fence, warning posts and/or guards?

Maybe the UN has a global minefield dataset. In general I think the country teams can handle this themselves, as they always have more local knowledge than us.

KristiinaKerge commented 6 years ago

that's right @lynxlynxlynx local teams have more local knowledge, maybe I over think here

jaakla commented 6 years ago

I've been in several places in countries where you can get easily arrested (or even killed) by just being in a place where you are not supposed to be, and there is no signage about that. Especially walking with GPS and mapping is quite a sensitive sport - think anything even remotely linked to military, security, industrial intelligence or crime-related activities, and in some countries you cannot enter any 'private land' without permission, see this warning for example. But this is indeed a knowledge only locals can provide. We/You can probably only provide technical tool to map such off-limits locations.

kristiinapalu commented 6 years ago
  1. It should take 12h of development and can be developed with any developer
  2. Need to separate the areas and if the user wants to add the trashpoint, then it's prohibited?
  3. Need someone who can define and manage these areas
lynxlynxlynx commented 6 years ago

This is out of scope if you ask me. Our goal is to map the waste, not areas potentially dangerous for mapping (anything).

krishaamer commented 6 years ago

@kristiinapalu What's exactly the spec for the "it" that would take 12h of dev?

kristiinapalu commented 6 years ago

@krishaamer - Sorry for not explaining. ‘It’ would mean that within 12h dev creates:

  1. Table for information about prohibited areas;
  2. The administrative possibility to add/edit prohibited areas (someone needs to insert the areas as well (not the developer));
  3. Display of the areas (how it’s going look on the map) and
  4. Check if user created trash points are outside the restricted areas
jaakla commented 6 years ago

add/edit prohibited areas

Drawing and editing of areas as polygons on map can be quite complex task, 2 orders of magnitude more tricky than adding and editing points on map. Polygons in general may include islands, holes, complex shapes following complex rivers or shorelines, users can easily draw invalid ones (with self-crossings, overlaps) etc. Maybe I'm overthinking here - if it is about few simple polygons then that would not be that difficult. How do you imagine this to work - any sample?

kristiinapalu commented 6 years ago

@jaakla Thank you for your feedback. I'll try to explain.

First of all, with this task, we need a developer who has knowledge of Google maps API's.

There is not need to develop code to display and mark polygons on Google maps, you can use this git repository for that: https://github.com/react-community/react-native-maps#polygon-creator

The developer needs to:

  1. save marked points to the database and display them to users.
  2. I hope that the same GIT library has a function for detecting if user marke is inside a restricted area.

This dev 12h time isn't to develop the polygons.

Please let me know if I have misunderstood this task

jaakla commented 6 years ago

Yep, this component function seems to cover the most basic case: adding (no editing) of simple and small low-accuracy polygons, and this could be enough for many or even most cases. This library does not seem to have "point in polygon" algorithms. This could become complex for generic case also, but here is one simple Java one which works with simple cases (no holes/islands,self-intersections, no crossing 180-degree line etc):

static boolean isPointInPolygon(PolygonGeometry poly, MapPos pos) {
    MapPosVector poses = poly.getPoses();
    int nvert = (int)poses.size();
    double testx = pos.getX(), testy = pos.getY();
    boolean c = false;
    int i, j;
    for (i = 0, j = nvert-1; i < nvert; j = i++) {
        MapPos vi = poses.get(i);
        MapPos vj = poses.get(j);
        if (((vi.getY()>testy) != (vj.getY()>testy)) &&
                    (testx < (vj.getX()-vi.getX()) * (testy-vi.getY()) / (vj.getY()-vi.getY()) + vi.getX())) {
            c = !c;
        }
    }
    return c;
}
kadry55 commented 6 years ago

This solution would also help to mark down areas where mobile phone usage is not recommended for safety reasons - we could allow just GPS coordinates/address based mapping there (without photos). Example from Kenya which they'd like to use: https://www.sde.co.ke/thenairobian/article/2001267529/muggings-paradise-seven-danger-spots-to-avoid-in-nairobi