This project is read-only.

 

Project Description
As all know, China's electronic map has specified offset. The goal of this project is to fix or correct the offset, and should as easy to use as possible.


Usage
There two public methods. One is ChinaGeoModel.EarthToChina, another is ChinaGeoModel.ChinaToEarth. The signature of echo methods is the same.

public static ChinaGeoModel EarthToChina/ChinaToEarth (
	GeoCoordinate earth/china,
	Action<ChinaGeoModel> callback = null,
	bool dirty = true
)


Parameters
earth/china
      A coordinate which is needs to fix. It can be Earth coordinates or China coordinates according to the EarthToChina or ChinaToEarth are choosing.

callback
      When fix was completed or beginning the query with a dirty flag, the callback will be invoked. The callback may invoke twice when there is no data found in cache and dirty flag was set.

dirty
      If set as true, invoke the callback when there is no data found in cache. Otherwise, not invoke the callback when there are found data in cache.


Return Value
      The model that is fixed or waiting for fixing.


The ChinaGeoModel is a model of the project. The properties are following:

Property Description
AutoFixed Get the original coordinate or fixed coordinate. Choose ChinaToEarth or EarthToChina by invoked method.
ChinaGeo Get the China’s coordinate which may original, fixed or null coordinate.
ChinaToEarth Get the EarthGeo when EarthGeo is not null, otherwise return the ChinaGeo.
EarthGeo Get the Earth’s coordinate which may original, fixed or null coordinate.
EarthToChina Get the ChinaGeo when ChinaGeo is not null, otherwise return the EarthGeo.
IsEffected Get the coordinate whether is fixed. When fix is not necessary, return true.
Timestamp Get the timestamp of fixed coordinate or min-value of timestamp when fix is not completed or necessary.



Sample

ChinaGeoHelper.EarthToChina(
    e.Position.Location,
    m =>
    {
        textBlock.Text = string.Format("Earth: {0}\nChina: {1}\nIsEffected: {2}\nTimestamp: {3}", m.EarthGeo, m.ChinaGeo, m.IsEffected, m.Timestamp);
    },
    dirty);

When performing the code, will be

dirty = true dirty = false
data has found in cache

Invoke the callback once.

Set textBlock with completed information.

The invoking should be synchronized.Return completed model.

Same as left cell.
data has not found in cache

Invoke the callback twice.

First time, set textBlock with uncompleted information; the invoking of this time should be synchronized.

Second time, set textBlock with completed information; the invoking of this time should be asynchronous. Then save to memory cache.

Return uncompleted model.

Invoke the callback once.

Same as the second time of left cell.

Return uncompleted model.



After usage, should save memory cache to file. Implemented with ChinaGeoHelper.SaveCache(). System will load the saved cache file in next starting.

Last edited Aug 9, 2012 at 9:19 AM by aimeast, version 2