This document is archived and information here might be outdated. Recommended version. |
The VCS associated with this spatial reference.
[Visual Basic .NET] Public Property VerticalCoordinateSystem As IVerticalCoordinateSystem
[C#] public IVerticalCoordinateSystem VerticalCoordinateSystem {get; set;}
[C++]
HRESULT get_VerticalCoordinateSystem(
IVerticalCoordinateSystem** vcs
);
[C++]
HRESULT putref_VerticalCoordinateSystem(
IVerticalCoordinateSystem* vcs
);
[C++] Parameters vcs [out, retval]
vcs is a parameter of type IVerticalCoordinateSystem** vcs
vcs is a parameter of type IVerticalCoordinateSystem*
ISpatialReferenceFactory3 srf3 = new SpatialReferenceEnvironmentClass();
IVerticalCoordinateSystem vcs1, vcs2;
vcs1 = srf3.CreateVerticalCoordinateSystem(5702);//NGVD_1929
vcs2 = srf3.CreateVerticalCoordinateSystem(5703);//NAVD_1988
ISpatialReference sr1, sr2;
sr1 = srf3.CreateSpatialReference(4269);//GCS_North_American_1983
((ISpatialReference3)sr1).VerticalCoordinateSystem = vcs1;
sr2 = srf3.CreateSpatialReference(5070);//NAD_1983_Contiguous_USA_Albers
((ISpatialReference3)sr2).VerticalCoordinateSystem = vcs2;
IProjectedCoordinateSystem pcs2 = (IProjectedCoordinateSystem)sr2;
IGeographicCoordinateSystem gcs1 = (IGeographicCoordinateSystem)sr1;
IGeographicCoordinateSystem gcs2 = pcs2.GeographicCoordinateSystem;
IHVCompositeDatumTransformationEditor edit = new HVCompositeDatumTransformationEditorClass();
IHVDatumTransformation hvdt;
edit.SetSpatialReferences(gcs1, gcs2);
hvdt = edit.CreateHVDatumTransformation(110011);//PE_VT_NGVD29_TO_NAVD88_NAD83_ECW
edit.Add(hvdt, esriTransformDirection.esriTransformForward);
IHVCompositeDatumTransformation hvcdt = edit.CreateNew();
ITransformation transform = (ITransformation)hvcdt;
IPoint pnt = new PointClass();
pnt.SpatialReference = sr1;
pnt.PutCoords(4, 3);
((IZAware)pnt).ZAware = true;
pnt.Z = 5;
((IGeometry5)pnt).ProjectEx5(sr2, esriTransformDirection.esriTransformForward, transform, false, 0, 0, ((int)esriProjectionHint.esriProjectionHintDefault) & ((int)esriProjectionHint.esriProjectionHintFindGeoTransformation));
double x, y, z;
pnt.QueryCoords(out x, out y);//10421841.071915826, 3982079.5947264349
z = pnt.Z;//1.5240030480060962
ISpatialReferenceFactory3Ptr ipSRF3(CLSID_SpatialReferenceEnvironment);
IVerticalCoordinateSystemPtr ipVCS1, ipVCS2;
ipSRF3->CreateVerticalCoordinateSystem(5702, &ipVCS1);//NGVD_1929
ipSRF3->CreateVerticalCoordinateSystem(5703, &ipVCS2);//NAVD_1988
ISpatialReferencePtr ipSR1, ipSR2;
ipSRF3->CreateSpatialReference(4269, &ipSR1);//GCS_North_American_1983
ISpatialReference3Ptr(ipSR1)->putref_VerticalCoordinateSystem(ipVCS1);
ipSRF3->CreateSpatialReference(5070, &ipSR2);//NAD_1983_Contiguous_USA_Albers
ISpatialReference3Ptr(ipSR2)->putref_VerticalCoordinateSystem(ipVCS2);
IProjectedCoordinateSystemPtr ipPCS2(ipSR2);
IGeographicCoordinateSystemPtr ipGCS1(ipSR1), ipGCS2;
ipPCS2->get_GeographicCoordinateSystem(&ipGCS2);
IHVCompositeDatumTransformationEditorPtr ipEdit(CLSID_HVCompositeDatumTransformationEditor);
IHVDatumTransformationPtr ipHvdt;
ipEdit->SetSpatialReferences(ipGCS1, ipGCS2);
ipEdit->CreateHVDatumTransformation(PE_VT_NGVD29_TO_NAVD88_NAD83_ECW, &ipHvdt);//110011
ipEdit->Add(ipHvdt, esriTransformForward);
IHVCompositeDatumTransformationPtr ipHvcdt;
ipEdit->CreateNew(&ipHvcdt);
ITransformationPtr ipTransform = ipHvcdt;
IPointPtr ipPnt(CLSID_Point);
ipPnt->putref_SpatialReference(ipSR1);
ipPnt->PutCoords(4, 3);
IZAwarePtr(ipPnt)->put_ZAware(VARIANT_TRUE);
ipPnt->put_Z(5);
((IGeometry5Ptr)ipPnt)->ProjectEx5(ipSR2, esriTransformForward, ipTransform, VARIANT_FALSE, 0, 0, (long)esriProjectionHintDefault&(long)esriProjectionHintFindGeoTransformation);
double x, y, z;
ipPnt->QueryCoords(&x, &y);//10421841.071915826,3982079.5947264349
ipPnt->get_Z(&z);//1.5240030480060962