I am working on a MapInfo plugin to convert MapInfo files to GeoJSON files.
I am having trouble matching up the object types of the two formats. Each GeoJSON object type is described in the documentation. The MapInfo object types are a bit more ambiguous. The best I can find is in the MapBasic reference file which says, for example:
- OBJ_INFO_TYPE value: OBJ_TYPE_REGION
- ID: 7
- Object type: Region Object
This is obvious enough but what exactly is a region? Is it analogous to a Polygon? Or is it any closed object?
Can anyone point me towards a decent definition of each object type?
Update 2010-02-03:
I sent a message to the MapInfo support people who pointed me towards a section in the MapInfo User Guide headed "Map Objects as Part of Layers" which spells things out perfectly. I still can't find this page in the guide that I have (version 10.5) so I'll paste the relevant section below for anyone else in my position.
Quote starts here:
MapInfo Professional are made up of layers of map objects. There are five basic types of objects:
- Regions: closed objects that cover a given area. These include polygons, ellipses, and rectangles. For example, country boundaries, postal code boundaries, sales territories.
- Point objects: represent single locations of data. For example, customer locations, restaurants, parking meters. Points can also be combined into multipoint objects.
- Line objects: open objects that cover a given distance. These include lines, polylines, and arcs. Examples are streets, rivers, power lines.
- Text objects: text that describes a map or another object, such as labels and titles.
- Collection objects: combination of region, line, and multipoint objects.
You can have each type of object in a separate layer (most common), or you can combine objects in the same layer.
Answer
A region in MapInfo (MapBasic) can match a Polygon or a MultiPolygon in GeoJSON. For the region to be a polygon it must: a) only have one polygon or b) only have one "main" polygon and one or more number of holes
If the region has multiple polygons with zero, one or more holes, I would consider this to be a MultiPolygon.
The GeoJSON describing is quite precise: "For type "Polygon", the "coordinates" member must be an array of LinearRing coordinate arrays. For Polygons with multiple rings, the first must be the exterior ring and any others must be interior rings or holes."
So you would need to check every part of the region to see if it is a hole in the main polygon or an extra polygon.
No comments:
Post a Comment