Hello,
I also get map from MySQL db displayed by uDig, but still can't do that with
GeoTools.
I load street features in MySQLDataStore without problems but i get null for
crs = fsStreets.getSchema().getCoordinateReferenceSystem().
I checked spatial_ref_sys table in MySQL and there is valid definition of
geographic
coordinate system with datum, prime meridian, unit etc. I also checked in
geometry_columns
table in MySQL db and my street table have SRID that correspond to
geographic coordinate
system in spatial_ref_sys table. I guess that
fsStreets.getSchema().getCoordinateReferenceSystem()
shouldn't return null?
I also try to force coordinate reference system to both WGS84 and
CARTESIAN_2D as:
if (crs == null) {
crs = DefaultGeographicCRS.WGS84;
//crs = DefaultEngineeringCRS.CARTESIAN_2D;
}
final MapContext map = new DefaultMapContext(crs);
map.addLayer(new DefaultMapLayer(fsStreets, streetsStyle));
but can't get features on map.
I am only managed to get this layer from mysql in context of other layers
added from
Postgis or directly from shapefile.
Can anyone help me about this. I don't know is problem in gt-mysql module or
maybe i am doing something wrong.
Thanks.
iceDice wrote:
>
> Hello again,
>
> I have made additional testing and i have following situation:
>
> When i add some layers from other data sources (shapefiles, postgres)
> and then add layer from mysql db i got all data displayed, but zoomed to
> layer from shapefile or postgres. But when i load only data from mysql i
> can't see anything. It seems to me that map bounds cannot be determined
> at all when using only mysql. I don't know what i am doing wrong, i use
> ogr2ogr
> to transform data from shapefile to mysql with option to keep CRS
> (-s_srs).
>
>
>
>
> iceDice wrote:
>>
>> Hello,
>>
>> I have problems to show data from MySQL db on map.
>>
>> I try to do that on following way:
>>
>> Map params = new HashMap();
>> params.put("dbtype", "mysql");
>> params.put("host", "localhost");
>> params.put("port", new Integer(3306));
>> params.put("database", "my_db");
>> params.put("user", "root");
>>
>> MySQLDataStoreFactory mySQLFactory = new MySQLDataStoreFactory();
>> MySQLDataStore mySQLDatastore = (MySQLDataStore)
>> mySQLFactory.createDataStore(params);
>> // Prepare feature sources
>> fsStreets = mySQLDatastore.getFeatureSource("streets");
>>
>> When i tried to display layer on JMapFrame i can't see anything. Values
>> for map bounds in JMapFrame
>> Status bar (min and max Lat and Lon) are all NaN.
>>
>> I check ogrinfo MySQL:my_db,user=root streets -so and get:
>> INFO: Open of `MySQL:my_db,user=root' using driver `MySQL' successful.
>> Layer name: streets
>> Geometry: Line String
>> Feature Count: 930
>> Extent: (19.559141, 46.026719) - (19.801404, 46.168960)
>> Layer SRS WKT:
>> GEOGCS["WGS 84",
>> DATUM["WGS_1984",
>> SPHEROID["WGS 84",6378137,298.257223563,
>> AUTHORITY["EPSG","7030"]],
>> AUTHORITY["EPSG","6326"]],
>> PRIMEM["Greenwich",0,
>> AUTHORITY["EPSG","8901"]],
>> UNIT["degree",0.01745329251994328,
>> AUTHORITY["EPSG","9122"]],
>> AUTHORITY["EPSG","4326"]]
>> FID Column = OGR_FID
>> Geometry Column = SHAPE
>> name: String (254.0)
>> oneway: String (254.0)
>> type: String (1.0)
>>
>> What can be problem here? I make table in MySQL from shapefile without
>> .prj file with
>> following command: ogr2ogr -f "MySQL"
>> MYSQL:"my_db,host=localhost,user=root,port=3306" -nln "streets" -a_srs
>> "EPSG:4326" streets.shp
>>
>> Also i try all of this with Postgis and everything works perfect.
>>
>> I hope so someone can help me about this.
>>
>> Best regards
>>
>
>
--
View this message in context:
http://n2.nabble.com/GeoTools-MySQL-tp3729388p3734837.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Come build with us! The BlackBerry® 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/devconf
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users