OK, I did it all in SQL (again, Manifold continues to amaze me). Going to have to do a blog post on this one :-) UPDATE (SELECT D.polyid, distratio, d.[Area (I)], dist FROM (SELECT max(distance(a.pt, b.pt)) as dist, a.polyid as polyid FROM (SELECT polyid, NewPoint(centroidX([Coord]), centroidY([coord])) as pt, distratio FROM D SPLIT BY Coords(id) AS [Coord] ) AS A, (SELECT polyid, NewPoint(centroidX([Coord]), centroidY([coord])) as pt, distratio FROM D SPLIT BY Coords(id) AS [Coord] ) AS B WHERE a.polyid = b.polyid GROUP BY a.polyid) AS C, D WHERE d.polyid = c.polyid ) SET distratio = [Area (I)]/dist assume you have a Drawing called D, with a unique ID called polyid, and a field called distratio that you need to update. It's as simple as this. I think there is probably a way to simplify this, and make the SQL more terse, but I did it this way out of a stream of consciousness. Took all of 4 minutes to write. I think if I spent more time, I could make the SQL shorter, but I figure, why bother - this seems to work. Now the big question: How do you do this with traditional GIS?? If you want to learn more SQL tricks like this, try my spatial SQL course here. Also, Introduction to Manifold 8, and Manifold Scripting.
|