예제 #1
0
        public void TestGenerateKmlDoc_SameModInterference()
        {
            Assert.AreEqual(KmlTestInfrastructure.StatValueField.IntervalList[0].Color.ColorStringForKml,
                            "800A0C80", "begin");
            KmlTestInfrastructure.StatValueField.FieldName = "同模干扰电平";
            Assert.AreEqual(KmlTestInfrastructure.StatValueField.FieldName, "同模干扰电平");
            List <MeasurePointInfo> measurePointList =
                KmlTestInfrastructure.MeasurePointList.Select(x =>
                                                              new MeasurePointInfo(x, KmlTestInfrastructure.StatValueField, 0.1)).ToList();

            Assert.AreEqual(KmlTestInfrastructure.StatValueField.IntervalList[0].Color.ColorStringForKml,
                            "800A0C80", "begin1");
            Assert.AreEqual(measurePointList[0].ColorStringForKml, "800A0C80", "middle");
            Assert.AreEqual(measurePointList[1].ColorStringForKml, "80670C0C");
            Assert.AreEqual(measurePointList[2].ColorStringForKml, "80FFFFFF");
            Assert.AreEqual(measurePointList[0].CoordinatesInfo,
                            "112.05,23.15,10 112.15,23.15,10 112.15,23.25,10 112.05,23.25,10");

            XmlDocument doc = GoogleKml.GenerateKmlDoc(measurePointList,
                                                       KmlTestInfrastructure.StatValueField, reader);

            Assert.AreEqual(KmlTestInfrastructure.StatValueField.IntervalList[0].Color.ColorStringForKml,
                            "800A0C80", "end");
            Assert.IsNotNull(doc.InnerXml);
            Assert.AreEqual(doc.InnerXml.IndexOf(@"<Style id=""Color-800A0C80"" xmlns="""">", System.StringComparison.Ordinal), 112);
            Assert.AreEqual(doc.InnerXml.IndexOf(@"<Placemark><name>测试点</name><styleUrl>Color-80670C0C</styleUrl>", System.StringComparison.Ordinal), 911);
        }
예제 #2
0
        public void TestGenerateKmlDoc_DifferentModInterference()
        {
            Assert.AreEqual(KmlTestInfrastructure.StatValueField.IntervalList[0].Color.ColorStringForKml,
                            "800A0C80", "begin");
            KmlTestInfrastructure.StatValueField.FieldName = "不同模干扰电平";
            List <MeasurePointInfo> measurePointList =
                KmlTestInfrastructure.MeasurePointList.Select(x =>
                                                              new MeasurePointInfo(x, KmlTestInfrastructure.StatValueField, 0.1)).ToList();

            Assert.AreEqual(measurePointList[0].ColorStringForKml, "80670C0C");
            Assert.AreEqual(measurePointList[1].ColorStringForKml, "80670C0C");
            Assert.AreEqual(measurePointList[2].ColorStringForKml, "80670C0C");

            XmlDocument doc = GoogleKml.GenerateKmlDoc(measurePointList,
                                                       KmlTestInfrastructure.StatValueField, reader);

            Assert.AreEqual(KmlTestInfrastructure.StatValueField.IntervalList[0].Color.ColorStringForKml,
                            "800A0C80", "end");
            Assert.IsNotNull(doc.InnerXml);
            Assert.AreEqual(doc.InnerXml,
                            @"<?xml version=""1.0"" encoding=""utf-16""?>"
                            + @"<kml xmlns=""http://earth.google.com/kml/2.1"">"
                            + @"<Document><name>KML地图</name>"
                            + @"<Style id=""Color-800A0C80"" xmlns=""""><LineStyle><width>1</width>"
                            + @"<color>FFFF8080</color></LineStyle><PolyStyle><color>800A0C80</color></PolyStyle></Style>"
                            + @"<Style id=""Color-80670C0C"" xmlns=""""><LineStyle><width>1</width>"
                            + @"<color>FFFF8080</color></LineStyle><PolyStyle><color>80670C0C</color></PolyStyle></Style>"
                            + @"<Style id=""Color-800A7B0C"" xmlns=""""><LineStyle><width>1</width>"
                            + @"<color>FFFF8080</color></LineStyle><PolyStyle><color>800A7B0C</color></PolyStyle></Style>"
                            + @"<Folder xmlns=""""><name>测试点序列</name>"
                            + @"<Placemark><name>测试点</name><styleUrl>Color-80670C0C</styleUrl>"
                            + @"<Polygon><extrude>1</extrude><altitudeMode>relativeToGround</altitudeMode>"
                            + @"<outerBoundaryIs><LinearRing>"
                            + @"<coordinates>112.05,23.15,10 112.15,23.15,10 112.15,23.25,10 112.05,23.25,10</coordinates>"
                            + @"</LinearRing></outerBoundaryIs></Polygon></Placemark>"
                            + @"<Placemark><name>测试点</name><styleUrl>Color-80670C0C</styleUrl>"
                            + @"<Polygon><extrude>1</extrude><altitudeMode>relativeToGround</altitudeMode>"
                            + @"<outerBoundaryIs><LinearRing>"
                            + @"<coordinates>112.15,23.25,10 112.25,23.25,10 112.25,23.35,10 112.15,23.35,10</coordinates>"
                            + @"</LinearRing></outerBoundaryIs></Polygon></Placemark>"
                            + @"<Placemark><name>测试点</name><styleUrl>Color-80670C0C</styleUrl>"
                            + @"<Polygon><extrude>1</extrude><altitudeMode>relativeToGround</altitudeMode>"
                            + @"<outerBoundaryIs><LinearRing>"
                            + @"<coordinates>112.25,23.35,10 112.35,23.35,10 112.35,23.45,10 112.25,23.45,10</coordinates>"
                            + @"</LinearRing></outerBoundaryIs></Polygon></Placemark>"
                            + @"</Folder></Document></kml>");
        }
예제 #3
0
        public ActionResult ExportKml(string fieldName,
                                      EvaluationInfrastructure infrastructure,
                                      StatValueFieldRepository repository)
        {
            StatValueField field = repository.FieldList[(int)fieldName.GetStatValueIndex()];

            if (field.IntervalList.Count == 0)
            {
                TempData["warning"] = "显示区间设置为空!请先设置区间。";
                return(RedirectToAction("PointsAnalysis"));
            }

            GoogleKml kml = new GoogleKml("framework.xml");
            string    absoluFilePath
                = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "uploads\\",
                               "Kmlresults-" + field.FieldName + DateTime.Today.ToString("yyyyMMdd"));

            kml.GenerateKmlFile(absoluFilePath,
                                infrastructure.Region.GetMeasureInfoList(field, EvaluationSettings.DistanceInMeter), field);
            return(File(new FileStream(absoluFilePath, FileMode.Open),
                        "application/octet-stream", Server.UrlEncode(
                            "Kmlresults-" + field.FieldName + DateTime.Today.ToString("yyyyMMdd") + ".kml")));
        }