Dict outputs atom-array?

MakePatchesNotWar's icon

Instead of the atoms i'd like to have floats so i can process them further. Can i keep this inside Max or do i have to go the javascript-route? And is that even going to work? (i have almost zero experience in javascript).

Max Patch
Copy patch and select New From Clipboard in Max.

Luvulongtime!

Jan M's icon

Hi Luvulongtime,

The problem is the coordinates are stored as arrays within arrays. [dict] doesn't support that format, independently if you process it with JS or not. You could read the file content into a string in JavaScript and parse it as a JSON object. Then you can iterate over the object.
Another issue is that there are two different formats of storing coordinates in that file depending if the geometry type is labeled as "Polygon" or "MultiPolygon".

Max Patch
Copy patch and select New From Clipboard in Max.

Here is a quick and dirty JS script that allows you to read and parse the data and get the coord by index (much like in your patch).

The JS script is attached! Make sure that the data file countries.geo.json is in your search path.

Cheers,

Jan

Sorry I was to hasty posting this. Use the second attached file (PARSECONTRIES1.JS). First one has a syntax error.

parseContries.js
js
parseContries1.js
js
MakePatchesNotWar's icon

Awesome, thanks!

"The problem is the coordinates are stored as arrays within arrays. [dict] doesn’t support that format, independently if you process it with JS or not."

Yeah, i had a hunch this might be the case. Thanks for sparing me the headache trying to troubleshoot that.

Time for me to go dissect the js :)

Luvulongtime!