From: Jody G. <jod...@gm...> - 2011-03-13 02:00:56
|
I really have to ask you to email the user list :-) That way others can help. You have fallen into the axis order problem. Where GIS systems assume longitude / latitude order - but us computer science guys assume x/y order. For more information please review the tutorial I sent earlier. Near the bottom is a single line "fix". System.setProperty("org.geotools.referencing.forceXY", "true"); I would need to check on rates, for the complete list of those offering commercial support: - http://docs.geotools.org/latest/userguide/guide/welcome/support.html I would recommend someone in your timezone for prompt service. -- Jody Garnett On Sunday, 13 March 2011 at 3:49 AM, Rajkumar wrote: > Hi Jody, > > Greetings. Thanks for your help. Once I added SRID, I am getting the > image, but layers are not aligned properly. > > > SimpleFeatureType TYPE = DataUtilities.createType("Airports", > "shape:Geometry:srid=4269,name:String"); // 4269 > > Regarding for the Data CoordinateReferenceSystem: > > CRS defs :GEOGCS["NAD83", > DATUM["North American Datum 1983", > SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]], > TOWGS84[1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0], > AUTHORITY["EPSG","6269"]], > PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], > UNIT["degree", 0.017453292519943295], > AXIS["Geodetic latitude", NORTH], > AXIS["Geodetic longitude", EAST], > AUTHORITY["EPSG","4269"]] > > For the MapPane CoordinateReferenceSystem is > > CRS defs :GEOGCS["GCS_North_American_1983", > DATUM["D_North_American_1983", > SPHEROID["GRS_1980", 6378137.0, 298.257222101]], > PRIMEM["Greenwich", 0.0], > UNIT["degree", 0.017453292519943295], > AXIS["Longitude", EAST], > AXIS["Latitude", NORTH]] > The collection are 264 > > Now I am getting two distinct locations, instead of the layers being > overlaid. I have attached the screenshot of the image. > > How much LISAsoft will charge for developer support? > > Thanks > > Best Regards > Rajkumar > > > > > Hi Rajkumar > > > > Welcome to GeoTools. > > > > The company I work for, LISAsoft, sells developer support allowing me to > > answer direct emails, and fix bugs, promptly. If you email the geotools > > user list you will find that both myself and others are around to try and > > help. > > > > When projecting from one CRS to another ... you need to have two > > coordinate reference systems, so your code is correct - your data is wrong > > :-) > > > > I notice this line: > > > > > SimpleFeatureType TYPE = DataUtilities.createType("testtype", > > > "shape:Geometry, name:String"); > > > > you should change it to specify the spatial reference system used - > > example "shape:Geometry:srid=4326" > > > > As shown in the javadocs: > > http://docs.geotools.org/stable/javadocs/org/geotools/data/DataUtilities.html#createType(java.lang.String,%20java.lang.String) > > > > Ask your data provider what the coordinate reference system is. Many > > organisations work with the same CRS all the time, and don't even both to > > write it down in the file. There is a DefaultGeographicCRS.WGS84 for > > lon/lat data for example. > > > > For more information please review the tutorial on the subject. > > http://docs.geotools.org/latest/tutorials/geometry/geometrycrs.html > > -- > > Jody Garnett > > > > On Saturday, 12 March 2011 at 12:37 AM, Rajkumar wrote: > > > > > > > > > Hi Jody, > > > > > > Greetings. I am very new to geotools. Here is my code and when I try to > > > click the mouse over a point, it is giving an exception. > > > > > > EVERE: It was not possible to get a projected bounds estimate > > > Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: > > > java.lang.IllegalArgumentException: Argument "sourceCRS" should not be > > > null. > > > at org.geotools.swing.tool.InfoTool.onMouseClicked(InfoTool.java:178) > > > at > > > org.geotools.swing.tool.MapToolManager.mouseClicked(MapToolManager.java:132) > > > > > > Code: > > > > > > > > > import com.vividsolutions.jts.geom.Geometry; > > > import com.vividsolutions.jts.io.WKTReader; > > > import java.awt.Color; > > > import org.geotools.data.DataUtilities; > > > import org.geotools.data.simple.SimpleFeatureCollection; > > > import org.geotools.factory.CommonFactoryFinder; > > > import org.geotools.feature.FeatureCollections; > > > import org.geotools.feature.simple.SimpleFeatureBuilder; > > > import org.geotools.map.DefaultMapContext; > > > import org.geotools.map.MapContext; > > > import org.geotools.referencing.crs.DefaultGeographicCRS; > > > import org.geotools.styling.ExternalGraphic; > > > import org.geotools.styling.FeatureTypeStyle; > > > import org.geotools.styling.Graphic; > > > import org.geotools.styling.PointSymbolizer; > > > import org.geotools.styling.Rule; > > > import org.geotools.styling.Stroke; > > > import org.geotools.styling.Style; > > > import org.geotools.styling.StyleBuilder; > > > import org.geotools.styling.StyleFactory; > > > import org.geotools.styling.Symbolizer; > > > import org.geotools.swing.JMapFrame; > > > import org.opengis.feature.simple.SimpleFeatureType; > > > import org.opengis.filter.Filter; > > > import org.opengis.filter.FilterFactory2; > > > import org.opengis.filter.expression.Function; > > > > > > > > > > > > > > > /* > > > * Creates some features having either Point or LineString as the > > > Geometry and displays them > > > * in a single MapLayer > > > */ > > > public class LinesAndPointsOrig { > > > > > > public static void main(String[] args) throws Exception { > > > new LinesAndPointsOrig().displayFeatures(); > > > } > > > > > > private void displayFeatures() throws Exception { > > > SimpleFeatureCollection features = createFeatureCollection(); > > > Style style = createStyle("shape"); > > > MapContext map = new DefaultMapContext(DefaultGeographicCRS.WGS84); > > > map.addLayer(features, style); > > > JMapFrame.showMap(map); > > > } > > > > > > private SimpleFeatureCollection createFeatureCollection() throws > > > Exception { > > > SimpleFeatureCollection fc = FeatureCollections.newCollection(); > > > SimpleFeatureType TYPE = DataUtilities.createType("testtype", > > > "shape:Geometry, name:String"); > > > SimpleFeatureBuilder fb = new SimpleFeatureBuilder(TYPE); > > > > > > Geometry g; > > > WKTReader reader = new WKTReader(); > > > > > > g = reader.read("POINT(1 1)"); > > > fc.add(fb.buildFeature(null, new Object[]{g, "p1"})); > > > > > > g = reader.read("POINT(2 2)"); > > > fc.add(fb.buildFeature(null, new Object[]{g, "p2"})); > > > > > > g = reader.read("POINT(3 3)"); > > > fc.add(fb.buildFeature(null, new Object[]{g, "p3"})); > > > > > > g = reader.read("POINT(4 4)"); > > > fc.add(fb.buildFeature(null, new Object[]{g, "p4"})); > > > > > > g = reader.read("LINESTRING(1 2, 4 5)"); > > > fc.add(fb.buildFeature(null, new Object[]{g, "line1"})); > > > > > > g = reader.read("LINESTRING(1 0, 4 3)"); > > > fc.add(fb.buildFeature(null, new Object[]{g, "line1"})); > > > > > > return fc; > > > } > > > > > > private Style createStyle(String geomPropertyName) { > > > // private Style createStyle() { > > > StyleFactory sf = CommonFactoryFinder.getStyleFactory(null); > > > FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); > > > > > > Rule pointRule = sf.createRule(); > > > Function getGeomFn = ff.function("geometryType", > > > ff.property(geomPropertyName)); > > > Filter pointFilter = ff.equals(getGeomFn, ff.literal("Point")); > > > pointRule.setFilter(pointFilter); > > > pointRule.setElseFilter(false); > > > > > > Graphic graphic = sf.getDefaultGraphic(); > > > graphic.graphicalSymbols().clear(); > > > //ExternalGraphic external = sf.createExternalGraphic( > > > "file:///C:/Users/rajkumar/riaexworkspace/metar/src/images/aircraftsmall.png", > > > "image/gif"); > > > > > > //ExternalGraphic eGr = sb.createExternalGraphic(SPRITE_IMAGE_URL, > > > "image/png"); > > > //graphic.graphicalSymbols().add( eGr ); > > > > > > // graphic.graphicalSymbols().add(sf.getCircleMark()); > > > graphic.graphicalSymbols().add(sf.getTriangleMark()); > > > > > > //graphic.graphicalSymbols().add(external); > > > > > > Symbolizer sym = sf.createPointSymbolizer(graphic, geomPropertyName); > > > // Symbolizer sym =sf.createPointSymbolizer(graphic,""); > > > pointRule.symbolizers().add(sym); > > > > > > Rule lineRule = sf.createRule(); > > > lineRule.setIsElseFilter(true); > > > Stroke stroke = sf.createStroke(ff.literal(Color.BLUE), > > > ff.literal(1.0f)); > > > Symbolizer lineSym = sf.createLineSymbolizer(stroke, > > > geomPropertyName); > > > lineRule.symbolizers().add(lineSym); > > > > > > FeatureTypeStyle fts = sf.createFeatureTypeStyle(new > > > Rule[]{pointRule, lineRule}); > > > Style style = sf.createStyle(); > > > style.featureTypeStyles().add(fts); > > > return style; > > > } > > > } > > > > > > I greatly appreciate your help. > > > > > > Thanks > > > Rajkumar > > > -- > Rajkumar > 408-306-8666 > RIAEX Inc. Sunnyvale > CA > > ------------ > CONFIDENTIALITY and SECRECY NOTICE: This electronic message > transmission(including any attachments) are covered by the Electronic > Communications Privacy Act, 18 U.S.C. Sections 2510-2521 and contain > information that is proprietary, confidential and/or privileged. The > information is intended only for the use of the individual(s) or entity > named above. In no event > shall this email be delivered to anyone other than the intended recipient > or original sender and violation may be considered a breach of law fully > punishable by various international courts. If you are not the intended > recipient of this e-mail (or the person responsible for delivering this > document to the intended recipient), you are hereby notified that any > dissemination, distribution, printing or copying of this e-mail, and any > attachment thereto, is strictly prohibited to the intended recipient only > and violation of this condition may infringe upon copyright, trademark, > patent, or other laws protecting proprietary and, or, intellectual > property. Unless otherwise explicitly stated, this e-mail does not > constitute a contractual offer, acceptance or amendment and nothing > contained in this message or in any attachment shall satisfy the > requirements for a written agreement of any kind under any statute > governing electronic transactions. If you have received this electronic > transmission in error, please notify the sender immediately by replying to > sender at the reply address and the address listed in the "From:" field > and then erase/delete the email and erase or destroy any copies that you > may have in any form or media immediately. > ------------------------------ > > Attachments: > - Capture.PNG > > |