Serialize Map Projection

Feb 9, 2011 at 5:40 PM

When saving a project, I would like to serialize the currently used projection of the map. To achieve this task I need to add the [Serialize] attribute ProjectionInfo and GeographicInfo. However, this would introduce a dependency of DotSpatial.Projections on DotSpatial.Serialization.

Is this a problem? Any other suggestion how to serialize the map projection, without introducing the new dependency?

Feb 9, 2011 at 5:50 PM

Yes, just create a string property that is serialized that stores the esri string.  In the property getter, you use "Projection.ToEsriString()" and then in the setter you can use "Projection.ReadEsriString(value)".  Alternately you can add the dependency, since I think almost everything else has a dependency to Serialization.  But I think Mathew was hoping to start trimming back some of our cross-dependency.  If you use the string variant, you will not be able to serialize any projection that is not expressible as an esri string, however.  That doesn't mean that ESRI has to support it, only that our program has to be able to parse all the necessary parameters into the esri text format.  I think you should be fine if you use that model.  Technically, I thought this pattern had already been implemented somewhere, but maybe on a layer and not on the map itself.



Feb 16, 2011 at 1:59 AM

I found that when creating a new Map using var map1 = new Map(), Map.Projection is automatically set to KnownCoordinateSystems.Geographic.World.WGS84.

Is this by design?