コード例 #1
0
        private static StringBuilder GetKmlDataBuilder(IEnumerable <FeatureLayer> featureLayers)
        {
            StringBuilder builder   = new StringBuilder();
            KmlGeoCanvas  kmlCanvas = new KmlGeoCanvas();

            Proj4Projection proj = new Proj4Projection();

            proj.InternalProjectionParametersString = GisEditor.ActiveMap.DisplayProjectionParameters;
            proj.ExternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();
            proj.Open();

            kmlCanvas.BeginDrawing(builder, proj.ConvertToExternalProjection(GisEditor.ActiveMap.CurrentExtent), GeographyUnit.DecimalDegree);
            featureLayers.ForEach(l =>
            {
                Proj4ProjectionInfo projectionInfo = l.GetProj4ProjectionInfo();
                if (projectionInfo != null)
                {
                    projectionInfo.ExternalProjectionParametersString = Proj4Projection.GetWgs84ParametersString();
                    projectionInfo.SyncProjectionParametersString();
                }

                l.Open();
                l.Draw(kmlCanvas, new Collection <SimpleCandidate>());
            });
            kmlCanvas.EndDrawing();
            return(builder);
        }
コード例 #2
0
        public static void SaveKmlData(IEnumerable <FeatureLayer> featureLayers, KmlParameter parameter)
        {
            StringBuilder builder   = new StringBuilder();
            GeoCanvas     kmlCanvas = new KmlGeoCanvas();

            if (parameter.Is3DKml)
            {
                kmlCanvas = new Kml3DGeoCanvas();
                ((Kml3DGeoCanvas)kmlCanvas).ZHeight = parameter.ZHeight;
            }
            Proj4Projection proj = new Proj4Projection();

            proj.InternalProjectionParametersString = GisEditor.ActiveMap.DisplayProjectionParameters;
            proj.ExternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();
            proj.Open();

            kmlCanvas.BeginDrawing(builder, proj.ConvertToExternalProjection(GisEditor.ActiveMap.CurrentExtent), GeographyUnit.DecimalDegree);
            featureLayers.ForEach(l =>
            {
                Proj4ProjectionInfo projectionInfo = l.GetProj4ProjectionInfo();
                if (projectionInfo != null)
                {
                    projectionInfo.ExternalProjectionParametersString = Proj4Projection.GetWgs84ParametersString();
                    projectionInfo.SyncProjectionParametersString();
                }

                l.Open();
                l.Draw(kmlCanvas, new Collection <SimpleCandidate>());
            });
            kmlCanvas.EndDrawing();
            using (StreamWriter sw = new StreamWriter(parameter.PathFileName))
            {
                sw.Write(builder.ToString());
                sw.Close();
            }
        }