예제 #1
0
        public TemplateRendererTests(ITestOutputHelper logger)
        {
            this.logger = logger;

            for (int i = 0; i < sequence.Length; i++)
            {
                KmlCameraParameterValues kmlCameraParameterValues = new KmlCameraParameterValues();
                kmlCameraParameterValues.seq = i;
                sequence[i] = kmlCameraParameterValues;
            }
        }
예제 #2
0
        private KmlCameraParameterValues[] NextKmlCameraParameterValues(int seq)
        {
            int size = Math.Max(Math.Min(seq, sequence.Length) - sequence_position, 0);

            KmlCameraParameterValues[] kmlCameraParameterValues = new KmlCameraParameterValues[size];
            for (int i = 0; i < size; i++)
            {
                kmlCameraParameterValues[i] = sequence[sequence_position + i];
            }
            sequence_position += size;
            return(kmlCameraParameterValues);
        }
        public void RazorMultiTrackTest()
        {
            string razorMultiTrackCameraTemplate = @"
@{ var updates = Model.multitrack.GetUpdates(); }
<?xml version='1.0' encoding='UTF-8'?>
<kml
  xmlns='http://www.opengis.net/kml/2.2'
  xmlns:gx='http://www.google.com/kml/ext/2.2'
>
  <NetworkLinkControl>
    <cookie>[email protected]</cookie>
    <cookie>[email protected]</cookie>
    <Update>
      <Create>
        <gx:MultiTrack targetId='pp'>
          <gx:Track>
            @foreach (var update in updates) {
            <gx:coord>
              @update.longitude
              @update.latitude
              @update.altitude
            </gx:coord>
            }
            @foreach (var update in updates) {
            <gx:angles>
              @update.heading
              @update.tilt
              @update.roll
            </gx:angles>
            }
          </gx:Track>
        </gx:MultiTrack>
      </Create>
    </Update>
  </NetworkLinkControl>
</kml>";
            KmlCameraParameterValues kmlCameraParameterValues = new KmlCameraParameterValues();

            string renderedKml = (
                new TemplateRendererFactory((message, details) => "renderer error: message({message}), details({details})")
                .newTemplateRenderer <KmlCameraParameterValues>(razorMultiTrackCameraTemplate)
                .Render(kmlCameraParameterValues)
                );

            logger.WriteLine($"renderedKml({renderedKml})");
        }
        public void TestCamerTemplateScriptRendering()
        {
            var kmlLiveCam = new KmlLiveCam(
                new LiveCamEntity(
                    new LiveCamLensEntity("camera", "return $\"seq({seq})\";"),
                    new LiveCamLensEntity("link", "return $\"lensUrl({lensUrl})\";")
                    )
                );
            KmlCameraParameterValues camValues = new KmlCameraParameterValues {
                seq = 678
            };
            KmlCameraParameterValues linkValues = new KmlCameraParameterValues {
                listenerUrl = "hey!", alias = "a", lens = "l"
            };

            Assert.Equal("seq(678)", kmlLiveCam.GetLens("camera").Render(camValues));
            Assert.Equal("lensUrl(hey!//a/l)", kmlLiveCam.GetLens("link").Render(linkValues));
        }
        public void TestCamerTemplateTextRendering()
        {
            var kmlLiveCam = new KmlLiveCam(
                new LiveCamEntity(
                    new LiveCamLensEntity("camera", "<cam({seq})"),
                    new LiveCamLensEntity("link", "<link({alias},{lensUrl})")
                    )
                );
            KmlCameraParameterValues camValues = new KmlCameraParameterValues
            {
                seq = 99
            };
            KmlCameraParameterValues linkValues = new KmlCameraParameterValues
            {
                liveCamUriPath = "lcp",
                alias          = "a76"
            };

            Assert.Equal("<cam(99)", kmlLiveCam.GetLens("camera").Render(camValues));
            Assert.Equal("<link(a76,/lcp/a76/)", kmlLiveCam.GetLens("link").Render(linkValues));
        }