Hi all,
I found a code snippet to generate a SVG file:
http://osgeo-org.1803224.n2.nabble.com/How-to-find-added-geometry-in-svg-td5510127.html
I do not know if it's the best way, but at least it worked for me. The
code example
is a refactored version of the following code:
http://www.javadocexamples.com/java_source/org/geotools/svg/GenerateSVG.java.html
In this case I do not know whether it is appropriate to update the
documentation (request or DIY). Now I have another problem: How to generate
an image with several overlapping layers. I tried to simply add a new layer
in MapContext but did not work =(
[]
On 27 June 2011 16:10, Odilon Lima <[email protected]> wrote:
> Hi Michael,
>
> Thanks for reply. Gustavo helps me to solve the problem. Basically he
> changed the place where layer was added and takes the bounds from
> MapContext, as follow:
>
> try {
>
> Style shpStyle = SLD.createPolygonStyle(Color.YELLOW, null,
> 0.0f);
> FileDataStore dataStore = FileDataStoreFinder.getDataStore(new
> File("/home/mesquita/shapes/Municipios.shp"));
>
> SimpleFeatureSource shapefileSource =
> dataStore.getFeatureSource();
>
> final MapContext map = new DefaultMapContext();
> map.addLayer(shapefileSource, shpStyle);
>
> ReferencedEnvelope envelope = new
> ReferencedEnvelope(map.getLayerBounds(),
> map.getCoordinateReferenceSystem());
> map.setAreaOfInterest(envelope);
>
> saveImage(map, "/home/mesquita/image.jpg");
> }
>
> catch (IOException ex) {
> Logger.getLogger(Teste.class.getName()).log(Level.SEVERE,
> null, ex);
> }
>
>
> Now, I am facing another problem: generate a SVG file. I run the sample
> code and the SVG generated has 0 bytes =(.
> Anyone know how to fix it?
>
> []
>
>
> On 27 June 2011 01:01, Michael Bedward <[email protected]> wrote:
>
>> Hello Odilon,
>>
>> You could adapt the JMapPane.setTransforms method, which centres the
>> map in the display area, to create an AffineTransform which you then
>> pass to the renderer.
>>
>> Michael
>>
>>
>> On 26 June 2011 06:31, Odilon Lima <[email protected]> wrote:
>> > Hi all,
>> >
>> > I passed a CRS for ReferencedEnvelope constructor and now I get a
>> rendered
>> > image, but it is not centered. Does anyone know how can I fix this?
>> >
>> > Thanks in advance.
>> >
>> > On 24 June 2011 21:02, Odilon Lima <[email protected]> wrote:
>> >>
>> >> Hi all,
>> >>
>> >> I am also having trouble generating an image. I tried to run the
>> following
>> >> code:
>> >>
>> >> Style shpStyle = SLD.createPolygonStyle(Color.YELLOW, null, 0.0f);
>> >> FileDataStore dataStore =
>> FileDataStoreFinder.getDataStore(new
>> >> File("/home/odilon/mapas/AESA/Municipios/Municipios.shp"));
>> >> SimpleFeatureSource shapefileSource =
>> >> dataStore.getFeatureSource();
>> >>
>> >> final MapContext map = new DefaultMapContext();
>> >> ReferencedEnvelope envelope = new ReferencedEnvelope(0.0,
>> >> 300.0, 0.0, 600.0, null);
>> >> map.setAreaOfInterest(envelope);
>> >> map.addLayer(shapefileSource, shpStyle);
>> >> saveImage(map, "/home/odilon/image.jpg");
>> >> Where the saveImage method is the same of the example and as result I
>> got
>> >> a blank image.
>> >>
>> >> Thanks in advance.
>> >>
>> >> On 22 June 2011 08:55, Gustavo Mesquita <[email protected]>
>> >> wrote:
>> >>>
>> >>> No I did not. I only used the method 'Envelope fixAspectRatio
>> (Rectangle
>> >>> r,
>> >>> Envelope mapArea)' from JMapPane because without this method the image
>> >>> has
>> >>> the same aspect ratio as the image size (the Rectangle object) and
>> this
>> >>> is
>> >>> not good. I needed that image in BufferedImage had the same appearance
>> >>> and
>> >>> aspect shown in JMapPane.
>> >>>
>> >>> Thanks one more time.
>> >>>
>> >>> -----
>> >>> Gustavo Mesquita da Silva.
>> >>> Brazilian Navy Hydrographic Center
>> >>> NiterĂ³i, Rio de Janeiro - Brazil
>> >>> --
>> >>> View this message in context:
>> >>>
>> http://osgeo-org.1803224.n2.nabble.com/Need-to-save-the-JMapPane-content-to-Image-file-tp6495634p6503922.html
>> >>> Sent from the geotools-gt2-users mailing list archive at Nabble.com.
>> >>>
>> >>>
>> >>>
>> ------------------------------------------------------------------------------
>> >>> Simplify data backup and recovery for your virtual environment with
>> >>> vRanger.
>> >>> Installation's a snap, and flexible recovery options mean your data is
>> >>> safe,
>> >>> secure and there when you need it. Data protection magic?
>> >>> Nope - It's vRanger. Get your free trial download today.
>> >>> http://p.sf.net/sfu/quest-sfdev2dev
>> >>> _______________________________________________
>> >>> Geotools-gt2-users mailing list
>> >>> [email protected]
>> >>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>> >>
>> >>
>> >>
>> >> --
>> >> Odilon Lima
>> >
>> >
>> >
>> > --
>> > Odilon Lima
>> >
>> >
>> ------------------------------------------------------------------------------
>> > All the data continuously generated in your IT infrastructure contains a
>> > definitive record of customers, application performance, security
>> > threats, fraudulent activity and more. Splunk takes this data and makes
>> > sense of it. Business sense. IT sense. Common sense..
>> > http://p.sf.net/sfu/splunk-d2d-c1
>> > _______________________________________________
>> > Geotools-gt2-users mailing list
>> > [email protected]
>> > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>> >
>> >
>>
>
>
>
> --
> Odilon Lima
>
--
Odilon Lima
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users