brandonshults / pipoam

A tool for clipping points on a map using polygons.
https://www.youtube.com/watch?v=jotvK8W-6MM
28 stars 2 forks source link

Format for json file? #3

Closed c00ni closed 8 years ago

c00ni commented 8 years ago

Currently using a file that contains spawn points in this format

{
 "spawns": [
  {
   "spawntime": 39.34219999983907,
   "pauses": 1,
   "phasetime": 60,
   "lat": -33.758997849992824,
   "pausetime": 45,
   "lng": 151.09449409575524,
   "type": 101,
   "id": 7357990306773
  }]
}

But it's not being recognised. Happy to convert the json to a different hierarchy, what does the file have to look like? Or is there an example file you can give me?

Cheers

brandonshults commented 8 years ago

An example file is a good idea, I will add that when I can. For now, it expects an array of objects that have at least a "lat" and "lng" property, so your format always to be nearly there, all you need to do is take the array that is stored as "spawns"

brandonshults commented 8 years ago

With node you can probably convert it very quickly with something like:

fs.writeFileSync('./output.json', JSON.stringify(require('./input.json').spawns));

c00ni commented 8 years ago

Sorry to be a pain, I can't get it to load the points for the life of me. Each object has lat and lng properties...

I've tried a few iterations and the last file I've tried looks like this:

"spawns":[
  {
   "spawntime": 39.34219999983907,
   "pauses": 1,
   "phasetime": 60,
   "lat": -33.758997849992824,
   "pausetime": 45,
   "lng": 151.09449409575524,
   "type": 101,
   "id": 7357990306773
  },
  {
   "spawntime": 26.43859999999404,
   "pauses": 1,
   "phasetime": 60,
   "lat": -33.7596969058904,
   "pausetime": 30,
   "lng": 151.0950401006697,
   "type": 102,
   "id": 7357990306691
  }]

Are you able to fix it for me please?

brandonshults commented 8 years ago

Sure, just get rid of the "spawns": at the beginning so the file contains only a JavaScript Array Literal like this:

[{
   "spawntime": 39.34219999983907,
   "pauses": 1,
   "phasetime": 60,
   "lat": -33.758997849992824,
   "pausetime": 45,
   "lng": 151.09449409575524,
   "type": 101,
   "id": 7357990306773
  },
  {
   "spawntime": 26.43859999999404,
   "pauses": 1,
   "phasetime": 60,
   "lat": -33.7596969058904,
   "pausetime": 30,
   "lng": 151.0950401006697,
   "type": 102,
   "id": 7357990306691
  }]
c00ni commented 8 years ago

It seems to not work. It doesn't error but just nothing happens after loading the file?

brandonshults commented 8 years ago

It currently doesn't recenter itself after the points are loaded and doesn't indicate that points have loaded so if the points load outside of the visible area you won't notice a difference. If you zoom your map out all the way can you see points on the map? It looks like those sample lat/lng you have are near Sydney Australia?

c00ni commented 8 years ago

They are indeed in Sydney, Australia :)

Okay, so I just tried from a few different browsers and eventually got it working. Chrome on Windows 7 x86 was what I was trying initially. I realised I didn't see the hand or polygons. Then I tried connecting to the box using Chrome on OSX. This didn't even load the map tiles after putting in the API key. Finally I tried Safari on OSX and it worked. Either I have terribly configured browsers (I really didn't think so???) or there is something else crazy happening.

Thanks for your help, will tinker around a bit and hopefully it's completely compatible with https://github.com/seikur0/PGO-mapscan-opt which is what I'm using.

brandonshults commented 8 years ago

Well, I haven't taken much care to expand the browser support. I'm using browser features such as fetch and es2015 promises without polyfills. That being said, Chrome would have to be pretty far out of date (Like maybe april 2015?) for those features to be missing, so it's likely something else. I will take a look, thanks for keeping me updated on your progress.