Examples of WKTReader


Examples of com.vividsolutions.jts.io.WKTReader

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        Geometry geom = null;
        if (value != null) {
            try {
                WKTReader reader = new WKTReader();
                geom = reader.read(value);
                geom.setSRID(4326);
            } catch (ParseException ex) {
                Logger.getLogger(GeometryConverter.class.getName()).log(Level.SEVERE, null, ex);
            }

Examples of com.vividsolutions.jts.io.WKTReader

                        // try and restore from WKT
                        String wkt = map.getBlackboard().getString(AOI_GEOMETRY);
                        if( wkt != null ){
                            // we got one!
                            GeometryFactory gf = JTSFactoryFinder.getGeometryFactory(null);
                            WKTReader reader = new WKTReader(gf);
                            try {
                                Geometry geometry = reader.read(wkt);
                                blackboard.put(AOI_GEOMETRY, geometry );
                            } catch (ParseException e) {
                                // no can do!
                            }
                        }

Examples of com.vividsolutions.jts.io.WKTReader

   * @throws Exception
   */
    @Test
  public void testDiffOnDonut() throws Exception {
        GeometryFactory geometryFactory = new GeometryFactory();
        WKTReader reader = new WKTReader( geometryFactory );
       
       
        //create feature collection with 2 geometries:
        //1. donut minus hole
        Polygon donut = (Polygon) reader.read("POLYGON ((100 100, 120 100, 120 120, 100 120, 100 100),(112 112, 118 112, 118 118, 112 118, 112 112))");
       
        //2. hole
        Polygon hole = (Polygon) reader.read("POLYGON ((112 112, 118 112, 118 118, 112 118, 112 112))");
       
        //add the two geometries to a FeatureCollection
        SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        b.setName( "Test" );
        b.add( "location", Polygon.class );
        SimpleFeatureType type = b.buildFeatureType();
        SimpleFeature donutFeature = SimpleFeatureBuilder.build(type, new Object[]{donut}, "fid.1");
        SimpleFeature holeFeature = SimpleFeatureBuilder.build(type, new Object[]{hole}, "fid.2");
        DefaultFeatureCollection fc = new DefaultFeatureCollection();
        fc.add(donutFeature);
        fc.add(holeFeature);
       
        //create iterator for collection
        FeatureIterator<SimpleFeature> iterator = fc.features();
       
        //create List<Geometry> for the simulated "drawn" shape
        Polygon userDrawnPoly = (Polygon) reader.read("POLYGON ((114 90, 130 90, 130 130, 114 130, 114 90))");
        List<Geometry> geoms = new ArrayList<Geometry>();
        geoms.add(userDrawnPoly);
       
        DifferenceFeatureCommand.runDifferenceOp(iterator, geoms);
        assertEquals(1, geoms.size());

Examples of com.vividsolutions.jts.io.WKTReader

        // utility class
    }
   
  public static Geometry read(final String wkt) throws ParseException, IllegalStateException {

    WKTReader reader = new WKTReader();
    Geometry geometry;

    geometry = reader.read(wkt);
   
    if(!geometry.isValid()){
        throw new IllegalStateException("the geometry is not valid: " + geometry.toText() ); //$NON-NLS-1$
    }

Examples of com.vividsolutions.jts.io.WKTReader

    @SuppressWarnings("deprecation")//$NON-NLS-1$
    public Object nativeToJava(TransferData transferData) {
      String string = (String) TextTransfer.getInstance().nativeToJava(
          transferData);

      WKTReader reader = new WKTReader();
      try {
        return reader.read(string);
      } catch (ParseException e) {
        // JONES
      }
      return null;
    }

Examples of com.vividsolutions.jts.io.WKTReader

        @SuppressWarnings("deprecation")
        public Object nativeToJava(TransferData transferData) {
            String string = (String) TextTransfer.getInstance().nativeToJava(
                    transferData);

            WKTReader reader = new WKTReader();
            try {
                Geometry read = reader.read(string);
                SimpleFeatureType ft=DataUtilities.createType("Temp Type", "*geom:"+read.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
               
                return SimpleFeatureBuilder.build( ft, new Object[]{read}, null );
            } catch (Exception e) {
                UiPlugin.log("", e); //$NON-NLS-1$

Examples of com.vividsolutions.jts.io.WKTReader

     *      java.lang.Object)
     */
    public void setPropertyValue( Object idObject, Object value ) {
        ID id = (ID) idObject;
        if (id.id == GEOM) {
            WKTReader reader = new WKTReader();
            try {
                geom = reader.read((String) value);
            } catch (ParseException e) {
                throw (RuntimeException) new RuntimeException( ).initCause( e );
            }
        }
       

Examples of com.vividsolutions.jts.io.WKTReader

    SimpleFeature newFeature = SimpleFeatureBuilder.build(featureType,
      noValues, "SomeNewProductID");

    // initialize a few fields
    // the first three attributes' names are taken from Constants.TYPE_SPEC
    newFeature.setDefaultGeometry((new WKTReader()).read("POINT(45.0 49.0)"))// name of attribute is geom
    newFeature.setAttribute("dtg", new Date());
    newFeature.setAttribute("dtg_end_time", new Date());
    newFeature.setAttribute("NAME", "New Product Name");
    newFeature.setAttribute("SKU", "011235813");
    newFeature.setAttribute("COST", 1.23);

Examples of com.vividsolutions.jts.io.WKTReader

    private WKTReader reader;
    private GeometryFactory factory;

    public GeoSPARQLWktDeserializer()
    {
        reader = new WKTReader();
        factory = GeoFactory.getDefaultGeometryFactory();
    }

Examples of com.vividsolutions.jts.io.WKTReader

    private GeometryFactory factory;


    public StSPARQLWktDeserializer()
    {
        reader = new WKTReader();
        factory = GeoFactory.getDefaultGeometryFactory();
    }
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.