Here is all my java code
import org.geotools.feature.SchemaException;

import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.geometry.jts.ReferencedEnvelope;


import org.geotools.map.*;
import org.geotools.referencing.CRS;
import org.geotools.referencing.crs.DefaultGeocentricCRS;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.geotools.renderer.lite.StreamingRenderer;
import org.geotools.renderer.style.IconStyle2D;
import org.geotools.resources.CRSUtilities;
import org.geotools.styling.*;
import org.geotools.swing.JMapFrame;
import org.geotools.swing.JMapPane;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.NoSuchAuthorityCodeException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;

public class App 
{
    public static void main( String[] args ) throws IOException, 
FactoryRegistryException, SchemaException, ClassNotFoundException, Exception
    {


        App app=new App();
        Map params= new HashMap();


        params.put("dbtype", "postgis");
        params.put("host", "localhost");
        params.put("port", "5432");
        params.put("database", "gis");
        params.put("user", "arnauld");
        params.put("passwd","root");
        //params.put(PostgisDataStoreFactory.LOOSEBBOX, "true" );
        params.put(PostgisDataStoreFactory.SCHEMA.key, "public" );

      DataStore pgDatastore = DataStoreFinder.getDataStore(params);



      FeatureSource osmline = pgDatastore.getFeatureSource("planet_osm_line");
      FeatureSource osmpoint = pgDatastore.getFeatureSource("planet_osm_point");
      FeatureSource 
osmpolygon=pgDatastore.getFeatureSource("planet_osm_polygon");
      FeatureSource osmroad=pgDatastore.getFeatureSource("planet_osm_roads");

 StyleBuilder sb= new StyleBuilder();

      ///Style des lignes
      LineSymbolizer line=  sb.createLineSymbolizer(Color.yellow,4);
      Style style=sb.createStyle(line);

      MapContext map=new DefaultMapContext();

CoordinateReferenceSystem crs=CRS.decode("EPSG:4326",true);

      //CoordinateReferenceSystem crs=DefaultGeographicCRS.WGS84;

      ReferencedEnvelope re=new ReferencedEnvelope(10.1602292, 
10.1741338,36.8468991,36.853853199999996, crs);

      map.setCoordinateReferenceSystem(crs);
      map.setAreaOfInterest(re);

      map.setTitle("Carte géographique de menzah 6");

      map.addLayer(osmline.getFeatures(),null);
      map.addLayer(osmpoint.getFeatures(),null);
      map.addLayer(osmroad.getFeatures(),null);
      map.addLayer(osmpolygon.getFeatures(), stylepolygon);

 GeometryFactory geo=new GeometryFactory();

Coordinate coord2 = new Coordinate(1131439.2747,4418792.6636);
                Coordinate coord3 = new Coordinate(1131081.0001,4418731.4201);
Coordinate coord1 = new Coordinate(1131270.8550,4418856.9693);

Coordinate[] coord={coord3,coord1,coord2};

    LineString lines =geo.createLineString(coord);

     SimpleFeatureType 
type=DataUtilities.createType("line","centerline:LineString:srid=4326,name:String");

     FeatureCollection<SimpleFeatureType, SimpleFeature> fcline = 
FeatureCollections.newCollection();

     SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(type);

     featureBuilder.add(lines);

     SimpleFeature feature = featureBuilder.buildFeature(null);

     fcline.add(feature);
map.addLayer(fcline, style);

JMapFrame frame =new JMapFrame(map);
       
        frame.enableStatusBar(true);
        frame.enableToolBar(true);
      
        frame.setSize(700,700);
        frame.setVisible(true);

This code draw line fine on the map. 

But in my file .xml i have rather this kind of data:

<bounds minlat='36.8468991' minlon='10.1602292' maxlat='36.853853199999996' 
maxlon='10.1741338' origin='CGImap 0.0.2' />
  <node id='243997182' timestamp='2008-01-29T14:58:17Z' uid='22060' 
user='chrischan' visible='true' version='1' changeset='708944' lat='36.8570917' 
lon='10.1670734' />
  <node id='243997183' timestamp='2008-01-29T14:58:17Z' uid='22060' 
user='chrischan' visible='true' version='1' changeset='708944' lat='36.8554984' 
lon='10.1685669' />
  <node id='243997185' timestamp='2009-05-12T23:28:34Z' uid='123321' 
user='Hatem' visible='true' version='2' changeset='1170291' lat='36.8536855' 
lon='10.1699434' />


When i construct the coordinate with x=lon and y=lat,  my line don't draw on a 
JMapframe interface.

How can i do to use without problem the lat and lon which are in my .xml file???

Ndefo Kamgne Arnauld

Cité Ettayour,Immeuble Bolbol 1,Appartement A2,Ariana

0021624249357




      
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to