Hi Gabriel,
I tried to force charset but i still can't get character displayed properly.
I need to display Serbian Latin characters and i tried both ISO-8859-2 and
UTF-8 charsets but without success. I printed in console label strings
before i created shapefile features and in console i get all characters
displayed properly.
Any ideas?
Best regards.
Gabriel Roldan wrote:
>
> Hi,
>
> shapefile charset encoding defaults to ISO-8859-1 (I think by spec). You
> can override that using the "charset" DataStoreFactory parameter:
>
> DataStoreFactorySpi factory = new ShapefileDataStoreFactory();
> Map<String, Serializable> create = new HashMap<String, Serializable>();
> create.put("url", newFile.toURI().toURL());
> create.put("create spatial index", Boolean.TRUE);
> create.put("charset", "UTF-8");
> ....
>
> Cheers,
> Gabriel
> iceDice wrote:
>> Hello,
>>
>> I have following issue. I created shapefile from feature collection on
>> this
>> way:
>>
>> final SimpleFeatureType TYPE = DataUtilities.createType("NewShapefile",
>> "geom:MultiLineString,name:String");
>> FeatureCollection<SimpleFeatureType, SimpleFeature> collection =
>> FeatureCollections.newCollection();
>> GeometryFactory geom_factory = new GeometryFactory();
>>
>> for (int i = 0; i < segments.size(); i++) {
>> LineString[] lsTemp = new LineString[1];
>> Coordinate c0 = ((MyLineSegment)segments.get(i)).p0;
>> Coordinate c1 = ((MyLineSegment)segments.get(i)).p1;
>> Coordinate[] coords = new Coordinate[2];
>> coords[0] = c0;
>> coords[1] = c1;
>>
>> LineString line_string = geom_factory.createLineString(coords);
>> lsTemp[0] = line_string;
>> MultiLineString line = geom_factory.createMultiLineString(lsTemp);
>> // here i get street names properly encoded in UTF-8
>> System.out.println(((MyLineSegment)
>> segments.get(i)).getStreetName());
>> SimpleFeature feature = SimpleFeatureBuilder.build(TYPE, new Object[]
>> {
>> line, ((MyLineSegment)segments.get(i)).getStreetName() }, null);
>> collection.add(feature);
>> }
>>
>> File newFile = new File("test.shp");
>> DataStoreFactorySpi factory = new ShapefileDataStoreFactory();
>> Map<String, Serializable> create = new HashMap<String, Serializable>();
>> create.put("url", newFile.toURI().toURL());
>> create.put("create spatial index", Boolean.TRUE);
>> ShapefileDataStore newDataStore = (ShapefileDataStore)
>> factory.createNewDataStore(create);
>> newDataStore.createSchema(TYPE);
>> newDataStore.forceSchemaCRS(DefaultGeographicCRS.WGS84);
>>
>> Transaction transaction = new DefaultTransaction("create");
>> String typeName = newDataStore.getTypeNames()[0];
>> FeatureStore<SimpleFeatureType, SimpleFeature> featureStore;
>> featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>)
>> newDataStore.getFeatureSource(typeName);
>> featureStore.setTransaction(transaction);
>>
>> try {
>> featureStore.addFeatures(collection);
>> transaction.commit();
>> } catch (Exception problem) {
>> problem.printStackTrace();
>> transaction.rollback();
>> } finally {
>> transaction.close();
>> }
>>
>> After i created shapefile i add it to the map and display it. However all
>> labels (street names) are not
>> properly coded in UTF-8.
>> I check that street name is in proper format before creating
>> SimpleFeature
>> object with it as parameter.
>> What i need to do to see shapefile rendered with labels in proper format?
>>
>> Best regards.
>
>
> --
> Gabriel Roldan
> OpenGeo - http://opengeo.org
> Expert service straight from the developers.
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
--
View this message in context:
http://n2.nabble.com/RenderingShapefile-tp3930876p3937344.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users