public void Release() { lock (LockThis1) { //try //{ // if (_preToID > 0) Proj4Wrapper.pj_free(_preToID); //} //catch { } //try //{ // if (_preFromID > 0) Proj4Wrapper.pj_free(_preFromID); //} //catch { } try { if (_fromID != IntPtr.Zero) { Proj4Wrapper.pj_free(_fromID); } } catch { } try { if (_toID != IntPtr.Zero) { Proj4Wrapper.pj_free(_toID); } } catch { } _fromSRef = _toSRef = null; _fromID = _toID = IntPtr.Zero; //_preFrom = _preTo = -1; } }
public void SetSpatialReferences(ISpatialReference from, ISpatialReference to) { if (from == null) { lock (LockThis1) { try { if (_fromID != IntPtr.Zero) { Proj4Wrapper.pj_free(_fromID); } } catch { } _fromID = IntPtr.Zero; _fromSRef = null; } } if (to == null) { lock (LockThis1) { try { if (_toID != IntPtr.Zero) { Proj4Wrapper.pj_free(_toID); } } catch { } _toID = IntPtr.Zero; _toSRef = null; } } if ((from != null && from.Datum == null) && (to != null && to.Datum != null)) { ISpatialReference toSRef = (ISpatialReference)to.Clone(); toSRef.Datum = null; this.ToSpatialReference = toSRef; this.FromSpatialReference = from; } else if ((from != null && from.Datum != null) && (to != null && to.Datum == null)) { this.ToSpatialReference = to; ISpatialReference fromSRef = (ISpatialReference)from.Clone(); fromSRef.Datum = null; this.FromSpatialReference = fromSRef; } else { this.ToSpatialReference = to; this.FromSpatialReference = from; } }