[Techtalk] Data structure for Earth slice data

Akkana Peck akkana at shallowsky.com
Thu Dec 4 03:06:14 UTC 2008


Kelly Jones writes:
> What's a good data structure/methodology for representing "slices" of
> the Earth?
> 
> More specific example: the set of points that are less than 1600 miles
> from Chicago AND less than 1000 miles from Albuquerque AND less than
> 800 miles from Dallas.
> 
> Obviously, the description above is one way to represent the data, but
> it's not very useful.
> 
> I want a representation that will:
> 
>  % Tell me if a given latitude/longitude is inside or outside the set.
> 
>  % For a given latitude, tell me what longitudes (if any) are inside
>  the set. Vica versa for a given longitude.
> 
>  % Tell me the area of my set.
> 
>  % Make it easy to map the boundary of my set
> 
> and so on. Thoughts?

Your specification of the set seems so general that the first thing
I would probably do is make an object-oriented representation of it.
(I'm not an "OO Uber Alles" sort, but OO is really well suited for
some sorts of problems and this is a perfect example.)

So I'd define an object type LandArea (pick your favorite name)
that includes methods like Contains(latitude, longitude), Area(), 
FindLongitudeRange(in latitude, out minLongitude, out maxLongitude)
and so forth. (I'm using pseudocode since you didn't mention which
language you're using.)

Then for definitions based on a list of cities and radii from each
city, like your example, all you need to start out is a list of
triples to store those data, then write the other functions in
terms of those.  If you later decide that you want to turn your
definitions into a set of line segments representing the outer
boundary or a list of rectangles or whatever, or if you want to have
multiple ways of specifying the set of points, you won't be facing
massive rewrites anywhere else.

	...Akkana


More information about the Techtalk mailing list