Select to view content in your preferred language

Can an SOE return a png image? Plus more...

519
1
01-30-2019 01:58 AM
chrisweaves
New Contributor II

Scenario: For my prototype I have published a service with one layer. The layer has 3 polygons with an entitlement attribute. Only one polygons entitlement is set to true. I need to write an SOE (in Java) to draw the polygons return an image, the polygon with the attribute set to true needs to be drawn differently, maybe a thicker line or an additional inner border or something along those lines. Unfortunately I don't have the luxury of drawing the polygons client side due to the shear volume of features.

I've worked through the bundled SDK samples but can't find anything appropriate.

So my questions are:

  • Can an SOE return an image? Ive been experimenting with the REST request appending &format=image but I just cant get my SOE to return a png
  • Is it possible to style particular features differently based on an attribute? If so, how would I update the legend to include the different styled feature

Thank you

Tags (2)
0 Kudos
1 Reply
nicogis
MVP Frequent Contributor

Yes you can return a image:

else if (outputFormat == "image")
{
            responseProperties = "{\"Content-Type\" : \"image/png\"}";
                            return Helper.ImageToByte(image, System.Drawing.Imaging.ImageFormat.Png);
}

public static byte[] ImageToByte(Image img, System.Drawing.Imaging.ImageFormat format)
        {
            byte[] byteArray = new byte[0];
            using (MemoryStream stream = new MemoryStream())
            {
                img.Save(stream, format);
                stream.Close();

                byteArray = stream.ToArray();
            }
            return byteArray;
        }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

For change render I advise use dynamic layer: About dynamic layers—Documentation (10.3 and 10.3.1) | ArcGIS Enterprise (for details see 'Changing symbols and renderers' Alternatives to server object extensions—Documentation (10.3 and 10.3.1) | ArcGIS Enterprise )

0 Kudos