Example #1
0
    public static ColorMap ColorMapForSatelliteImage(MapData mapData)
    {
        SatelliteImage satelliteImage = SatelliteImageService.getSatelliteImage();
        double         scale          = satelliteImage.getScale();

        int textureWidth  = (int)(mapData.GetWidth() * scale);
        int textureHeight = (int)(mapData.GetHeight() * scale);

        Color[] colorArray = new Color[textureWidth * textureHeight];
        if (!satelliteImage.hasSatelliteImage())
        {
            return(new ColorMap(colorArray, textureWidth, textureHeight));
        }

        MapDataSlice slice = mapData.AsSlice();

        for (int y = 0; y < textureHeight; y++)
        {
            int sliceY   = (int)(slice.GetY() * scale);
            int flippedY = satelliteImage.texture.height - (int)(sliceY + y) - 1;
            Array.ConstrainedCopy(satelliteImage.texture.GetPixels((int)(slice.GetX() * scale), flippedY, textureWidth, 1), 0, colorArray, (y * textureWidth), textureWidth);
        }

        return(new ColorMap(colorArray, textureWidth, textureHeight));
    }
 public void SatelliteImageLoadingWorks()
 {
     satelliteImage = SatelliteImageImporter.ReadSatelliteImage("Assets/Resources/satelliteTest.png", 827, 1024);
     Assert.True(satelliteImage.width == 827, "Wrong width!");
     Assert.True(satelliteImage.height == 1024, "Wrong height!");
     Assert.True(satelliteImage.hasSatelliteImage(), "A satellite image was not loaded!");
     Assert.True(satelliteImage.texture != null, "No texture was loaded!");
     Assert.True(satelliteImage.texture.GetPixels().Length == 827 * 1024, "Wrong number of pixels!");
 }
 public void LackOfImageFileCreatesEmptySatelliteImageObject()
 {
     satelliteImage = SatelliteImageImporter.ReadSatelliteImage("Assets/Resources/wrongfile.png", 10, 10);
     Assert.True(!satelliteImage.hasSatelliteImage(), "A satellite image was erroneously loaded!");
 }
Example #4
0
 public static bool UseSatelliteImage()
 {
     return(satelliteImage != null && satelliteImage.hasSatelliteImage() && useSatelliteImage);
 }