Package org.geotools.feature

Examples of org.geotools.feature.Feature


        FeatureTypeInfo meta = null;
        NameSpaceInfo namespace;
        Query query;

        FeatureSource source;
        Feature feature;
        String fid;
        FilterFactory filterFactory = FilterFactoryFinder.createFilterFactory();
        FidFilter fidFilter;

        try {
            for (Iterator it = request.getQueries().iterator(); it.hasNext();) {
                query = (Query) it.next();

                // the feature type name used in the content disposition response will match
                // the first feature type
                if (featureTypeName == null) {
                    featureTypeName = query.getTypeName();
                }

                meta = catalog.getFeatureTypeInfo(query.getTypeName());
                namespace = meta.getDataStoreInfo().getNameSpace();
                source = meta.getFeatureSource();

                List attrs = meta.getAttributes();

                List propNames = query.getPropertyNames(); // REAL LIST: be careful here :)
                List attributeNames = meta.getAttributeNames();

                for (Iterator iter = propNames.iterator(); iter.hasNext();) {
                    String propName = (String) iter.next();

                    if (!attributeNames.contains(propName)) {
                        String mesg = "Requested property: " + propName + " is "
                            + "not available for " + query.getTypeName() + ".  "
                            + "The possible propertyName values are: " + attributeNames;
                        throw new WfsException(mesg);
                    }
                   
                   
                }

                List extraGeometries = new ArrayList();
                List properties = new ArrayList();
                if (propNames.size() != 0) {
                    Iterator ii = attrs.iterator();
                   

                    while (ii.hasNext()) {
                        AttributeTypeInfo ati = (AttributeTypeInfo) ii.next();

                        //String attName = (String) ii.next();
                        LOGGER.finer("checking to see if " + propNames + " contains" + ati);

                        if (((ati.getMinOccurs() > 0) && (ati.getMaxOccurs() != 0))
                                || propNames.contains(ati.getName())) {
                            properties.add(ati.getName());
                        }
                       
                        //if(wfs.isFeatureBounding() && meta.getFeatureType().getAttributeType(ati.getName()) instanceof GeometryAttributeType
                        //        && !properties.contains(ati.getName())) {
                        //    properties.add(ati.getName());
                        //    extraGeometries.add(ati.getName());
                        //}
                        if(meta.getFeatureType().getAttributeType(ati.getName()) instanceof GeometryAttributeType
                                && !properties.contains(ati.getName())) {
                            properties.add(ati.getName());
                            extraGeometries.add(ati.getName());
                        }
                    }

                    query.setPropertyNames(properties);
                }
               
                // Add range to filter
                AttributeExpression geomAttb = filterFactory.createAttributeExpression(meta.getFeatureType(), meta.getFeatureType().getDefaultGeometry().getName());
                LiteralExpression pointExpr = filterFactory.createLiteralExpression(request.getPoint());
                DWithin dWithin = filterFactory.dwithin(geomAttb, pointExpr, request.getMaxRange(), request.getUnits());
                if (query.getFilter() == null) {
                    query.addFilter((Filter)dWithin);
                   
                } else {
                    And andFilter = filterFactory.and(Arrays.asList(new Filter[] { (Filter)dWithin, query.getFilter() }));
                    query.addFilter((Filter)andFilter);
                }
               
                LOGGER.fine("Query is " + query + "\n To gt2: " + query.toDataQuery(Integer.MAX_VALUE));

                //DJB: note if maxFeatures gets to 0 the while loop above takes care of this! (this is a subtle situation)
                FeatureCollection featuresCheck = source.getFeatures(query.toDataQuery(Integer.MAX_VALUE));
               
                // find nearest feature
                Unit fromUnit = SI.METER;
                Unit toUnit = UnitFormat.getInstance().parseUnit(request.getUnits());
                Converter unitConvert = fromUnit.getConverterTo(toUnit);
                Feature nearestFeature = null;
                double nearestDistance = 9e9;
                double nearestBearing = 0;
                for (Iterator sItr = featuresCheck.iterator(); sItr.hasNext();) {
                    Feature f = (Feature)sItr.next();
                    if (f.getDefaultGeometry() == null) continue;
                    DistanceOp op = new DistanceOp(request.getPoint(), f.getDefaultGeometry());
                    Coordinate[] co = op.closestPoints();
                    Measure m = DefaultGeographicCRS.WGS84.distance(new double[] { co[0].x, co[0].y, }, new double[] { co[1].x, co[1].y, });
                    if (m.doubleValue() > nearestDistance) continue;
                    nearestFeature = f;
                    nearestDistance = m.doubleValue();
View Full Code Here


        public boolean hasNext() {
            return wrapped.hasNext();
        }

        public Object next() throws NoSuchElementException {
            Feature base = wrapped.next();
            return new BoundedFeature(base, targetSchema);
        }
View Full Code Here

       
        // read and merge the features
        try {
            while (baseFeatureReader.hasNext()) {
                try {
                    Feature feature = baseFeatureReader.next();
                    String uniqueKey = (String)feature.getAttribute(featureUniqueKey);
                    //LOG.info("Read feature " + featureUniqueKey + ": " + uniqueKey);
                    if (!uniqueFeatureMap.containsKey(uniqueKey)) uniqueFeatureMap.put(uniqueKey, feature);
                    if (!uniqueFeatureMerger.containsKey(uniqueKey)) uniqueFeatureMerger.put(uniqueKey, new LineMerger());
                    LineMerger merger = uniqueFeatureMerger.get(uniqueKey);
                    merger.add(feature.getDefaultGeometry());
                } catch (NoSuchElementException e) {
                    LOG.warning("Error reading feature: " + e);
                } catch (IllegalAttributeException e) {
                    LOG.warning("Error reading feature: " + e);
                }
            }
        } catch (IOException e) {
            LOG.warning("Error reading features: " + e);
        }
        for (String uniqueKey : uniqueFeatureMerger.keySet()) {
            //LOG.info("Get merged: " + uniqueKey);
            Feature feature = uniqueFeatureMap.get(uniqueKey);
            LineMerger merger = uniqueFeatureMerger.get(uniqueKey);
            try {
                feature.setDefaultGeometry(new MultiLineString((LineString[])merger.getMergedLineStrings().toArray(new LineString[0]), feature.getDefaultGeometry().getFactory()));
            } catch (IllegalAttributeException e) {
                LOG.warning("Prolem setting new geometry: " + e);
            }
        }
        //LOG.info("Features="+uniqueFeatureMap.size());
View Full Code Here

        
      FeatureReader fr = ds.getFeatureReader(q, new DefaultTransaction() );
  
        while (fr.hasNext())
        {
          Feature f= fr.next();
          if (!alreadyThere(f.getDefaultGeometry()))
              lines.add(f.getDefaultGeometry());
        }
        fr.close();
}
View Full Code Here

     
      values[ft.find("gen_1")] = generalize(gfinal,tolerance1);;
      values[ft.find("gen_2")] = generalize(gfinal,tolerance1);;
      values[ft.find("gen_3")] = generalize(gfinal,tolerance1);;
     
      Feature f = ft.create(values);
      memorystore.addFeature(f);
   
    fs.addFeatures(memorystore.getFeatureReader("poly_county"));
   
  }
View Full Code Here

        
      FeatureReader fr = ds.getFeatureReader(q, new DefaultTransaction() );
  
        while (fr.hasNext())
        {
          Feature f= fr.next();
         
          f.getDefaultGeometry().setUserDataf.getAttribute(1) ); // sets CFCC in the geometry
         
          Integer interstate_num = null;
          Integer ushwy_num = null;
          Integer statehwy_num = null;
          String  other_nam = null;
         
          interstate_num = getInterstate(f);
          if (interstate_num == null)
          {
             ushwy_num  = getUShwy(f);
              if (ushwy_num == null)
            {
                  statehwy_num = getStateHwy(f);
                  if (ushwy_num == null)
              {
                       other_nam    = getOtherName(f);
              }
            }
          }
         
          if (interstate_num != null)
          {
            ArrayList al = (ArrayList) interstate.get(interstate_num);
            if (al ==null)
            {
              al = new ArrayList();
              interstate.put(interstate_num,al);
            }
            al.add( f.getDefaultGeometry() );
          }
          else if (ushwy_num != null)
          {
            ArrayList al = (ArrayList) ushighway.get(ushwy_num);
            if (al ==null)
            {
              al = new ArrayList();
              ushighway.put(ushwy_num,al);
            }
            al.add( f.getDefaultGeometry() );
          }
          else if (statehwy_num != null)
          {
            ArrayList al = (ArrayList) statehighway.get(statehwy_num);
            if (al ==null)
            {
              al = new ArrayList();
              statehighway.put(statehwy_num,al);
            }
            al.add( f.getDefaultGeometry() );
          }
          else //other
          {
            String name= (String) f.getAttribute("name");
            ArrayList al = (ArrayList) other.get(name);
            if (al ==null)
            {
              al = new ArrayList();
              other.put(name,al);
            }
            al.add( f.getDefaultGeometry() );           
          }
        }
        fr.close();
}
View Full Code Here

               values[ft.find("gen_1")] = generalize(g,tolerance1);
               values[ft.find("gen_2")] = generalize(g,tolerance2);
               values[ft.find("gen_3")] = generalize(g,tolerance3);
            values[ft.find(column)] = key;
           
             Feature f = ft.create(values);
             memorystore.addFeature(f);
            }
        }
   
  }
View Full Code Here

        
      FeatureReader fr = ds.getFeatureReader(q, new DefaultTransaction() );
  
        while (fr.hasNext())
        {
          Feature f= fr.next();
         
          BigDecimal tlidBD = (BigDecimal) f.getAttribute(1);
          Long tlid = new Long(tlidBD.longValue());
         
          if (tlid == null)
            throw new Exception("cchain has null tlid");
         
          completeChains.put(tlid, f.getAttribute(0));//linestring
        }
        fr.close();
}
View Full Code Here

        
      FeatureReader fr = ds.getFeatureReader(q, new DefaultTransaction() );
  
        while (fr.hasNext())
        {
          Feature f= fr.next();
          f.getFeatureType();
         
          BigDecimal polyidlBD = (BigDecimal) f.getAttribute(0);
          BigDecimal polyidrBD = (BigDecimal) f.getAttribute(1);
          BigDecimal tlidBD = (BigDecimal) f.getAttribute(2);
         
          if (tlidBD == null)
            throw new Exception("polylink has null tlid");
         
          if ( (polyidlBD == null) && (polyidrBD ==null) )
View Full Code Here

        
      FeatureReader fr = ds.getFeatureReader(q, new DefaultTransaction() );
  
        while (fr.hasNext())
        {
          Feature f= fr.next();
         
          BigDecimal polyidBD = (BigDecimal) f.getAttribute(1);
          Long polyid = new Long(polyidBD.longValue());
         
          if (polyid == null)
            throw new Exception("PIP  has null polyid");
         
          Geometry g = (Geometry) f.getAttribute(0);
          g.setUserData(polyid);
         
          PIP.insert(g.getEnvelopeInternal(),g);
        }
        fr.close();
View Full Code Here

TOP

Related Classes of org.geotools.feature.Feature

Copyright © 2018 www.massapicom. 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.