Package org.vfny.geoserver.global

Examples of org.vfny.geoserver.global.FeatureTypeInfo


        //   itterate through the the FeatureSources to release the locks
        //
        WFS wfs = request.getWFS();
        GeoServer config = wfs.getGeoServer();
        Data catalog = wfs.getData();
        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();
                    nearestBearing = calcBearing(co);
                }

                //GR: I don't know if the featuresults should be added here for later
                //encoding if it was a lock request. may be after ensuring the lock
                //succeed?
                FeatureCollection features = FeatureCollections.newCollection();
                if (nearestFeature != null) features.add(superFeature(nearestFeature, unitConvert.convert(nearestDistance), nearestBearing));
               
                // we may need to shave off geometries we did load only to make bounds
                // computation happy
                if(extraGeometries.size() > 0) {
                    List residualProperties = new ArrayList(properties);
                    residualProperties.removeAll(extraGeometries);
                    residualProperties.add("nearest_distance");
                    residualProperties.add("nearest_bearing");
                    String[] residualNames = (String[]) residualProperties.toArray(new String[residualProperties.size()]);
                    FeatureType targetType = DataUtilities.createSubType(superFeatureType(meta.getFeatureType()), residualNames);
                    features = new FeatureBoundsFeatureCollection(features, targetType);
                }

                results.addFeatures(meta, features);
            }
View Full Code Here


            maxFeatures = serverMaxFeatures;
        }

        StringBuffer typeNames = new StringBuffer();
        FeatureResults features;
        FeatureTypeInfo meta = null;
        NameSpaceInfo namespace;
        int resCount = results.getResultsetsCount();
        Map ftNamespaces = new HashMap(resCount);

        for (int resIndex = 0; resIndex < resCount; resIndex++) {
            features = results.getFeatures(resIndex);
            meta = results.getTypeInfo(resIndex);
            namespace = meta.getDataStoreInfo().getNameSpace();

            String uri = namespace.getUri();
            ftNames.declareNamespace(features.getSchema(), namespace.getPrefix(), uri);

            if (ftNamespaces.containsKey(uri)) {
                String location = (String) ftNamespaces.get(uri);
                ftNamespaces.put(uri, location + "," + meta.getName());
            } else {
                ftNamespaces.put(uri,
                    request.getBaseUrl() + "wfs/" + "DescribeFeatureType?typeName="
                    + meta.getName());
            }
        }

        System.setProperty("javax.xml.transform.TransformerFactory",
            "org.apache.xalan.processor.TransformerFactoryImpl");

        transformer.setIndentation(config.isVerbose() ? INDENT_SIZE : (NO_FORMATTING));
        transformer.setNumDecimals(config.getNumDecimals());
        transformer.setFeatureBounding(request.getWFS().isFeatureBounding());
        transformer.setEncoding(request.getWFS().getGeoServer().getCharSet());

        String wfsSchemaLoc = request.getSchemaBaseUrl() + "wfs/1.0.0/WFS-basic.xsd";

        transformer.addSchemaLocation("http://www.opengis.net/wfs", wfsSchemaLoc);

        for (Iterator it = ftNamespaces.keySet().iterator(); it.hasNext();) {
            String uri = (String) it.next();
            transformer.addSchemaLocation(uri, (String) ftNamespaces.get(uri));
        }

        transformer.setGmlPrefixing(request.getWFS().getCiteConformanceHacks());

        transformer.setSrsName(request.getWFS().getSrsPrefix() + meta.getSRS());
    }
View Full Code Here

            end("Operations");

            Collection featureTypes = wfs.getData().getFeatureTypeInfos()
                                         .values();
            FeatureTypeInfo ftype;

            for (Iterator it = featureTypes.iterator(); it.hasNext();) {
                ftype = (FeatureTypeInfo) it.next();

                //can't handle ones that aren't enabled.
                //and they shouldn't be handled, as they won't function.
                if (ftype.isEnabled()) {
                    handleFeatureType(ftype);
                }
            }

            end("FeatureTypeList");
View Full Code Here

        FeatureResults[] results, Style[] styles)
        throws IOException, AbortedException {
        int nLayers = results.length;
        int nConfigs = ((layers != null) && (layers.length >= nLayers))
            ? nLayers : 0;
        FeatureTypeInfo layerConfig = null;
        int defMaxDecimals = writer.getMaximunFractionDigits();

        for (int i = 0; i < nLayers; i++) {
            if (nConfigs == nLayers) {
                layerConfig = layers[i];
                writer.setMaximunFractionDigits(layerConfig.getNumDecimals());
            } else {
                writer.setMaximunFractionDigits(defMaxDecimals);
            }

            FeatureReader featureReader = null;

            try {
                LOGGER.fine("obtaining FeatureReader for "
                    + layerConfig.getName());
                featureReader = results[i].reader();
                LOGGER.fine("got FeatureReader, now writing");

                String groupId = null;

                //modified ch = delegate now changes style names to style
                //objects, so execute takes a style array.
                //if (styles == null) {
                groupId = layerConfig.getTypeName();

                //} else {
                //groupId = (String) styles.get(i);
                //}
                writer.write("<g id=\"" + groupId + "\" class=\"" + groupId
View Full Code Here

            maxFeatures = serverMaxFeatures;
        }

        StringBuffer typeNames = new StringBuffer();
        FeatureResults features;
        FeatureTypeInfo meta = null;
        NameSpaceInfo namespace;
        int resCount = results.getResultsetsCount();
        Map ftNamespaces = new HashMap(resCount);

        for (int resIndex = 0; resIndex < resCount; resIndex++) {
            features = results.getFeatures(resIndex);
            meta = results.getTypeInfo(resIndex);
            namespace = meta.getDataStoreInfo().getNameSpace();

            String uri = namespace.getUri();
            ftNames.declareNamespace(features.getSchema(),
                namespace.getPrefix(), uri);

            if (ftNamespaces.containsKey(uri)) {
                String location = (String) ftNamespaces.get(uri);
                ftNamespaces.put(uri, location + "," + meta.getName());
            } else {
                ftNamespaces.put(uri,
                    request.getBaseUrl() + "wfs/"
                    + "DescribeFeatureType?typeName=" + meta.getName());
            }
        }

        System.setProperty("javax.xml.transform.TransformerFactory",
            "org.apache.xalan.processor.TransformerFactoryImpl");

        transformer.setIndentation(config.isVerbose() ? INDENT_SIZE
                                                      : (NO_FORMATTING));
        transformer.setNumDecimals(config.getNumDecimals());
        transformer.setFeatureBounding(request.getWFS().isFeatureBounding());
        transformer.setEncoding(request.getWFS().getGeoServer().getCharSet());

        String wfsSchemaLoc = request.getSchemaBaseUrl()
            + "wfs/1.0.0/WFS-basic.xsd";

        transformer.addSchemaLocation("http://www.opengis.net/wfs", wfsSchemaLoc);

        for (Iterator it = ftNamespaces.keySet().iterator(); it.hasNext();) {
            String uri = (String) it.next();
            transformer.addSchemaLocation(uri, (String) ftNamespaces.get(uri));
        }

        transformer.setGmlPrefixing(request.getWFS().getCiteConformanceHacks());

        FeatureLock featureLock = results.getFeatureLock();

        if (featureLock != null) {
            transformer.setLockId(featureLock.getAuthorization());
        }

        transformer.setSrsName(request.getWFS().getSrsPrefix() + meta.getSRS());
    }
View Full Code Here

            LOGGER.info("curLock is " + curLock);

            String curTypeName = curLock.getFeatureType();
            Filter curFilter = curLock.getFilter();

            FeatureTypeInfo meta = catalog.getFeatureTypeInfo(curTypeName);
            NameSpaceInfo namespace = meta.getDataStoreInfo().getNameSpace();
            FeatureSource source = meta.getFeatureSource();
            FeatureResults features = source.getFeatures(curFilter);

            if( source instanceof FeatureLocking){
                ((FeatureLocking)source).setFeatureLock(fLock);
            }
            FeatureReader reader = null;

            try {
                for (reader = features.reader(); reader.hasNext();) {
                    Feature feature = reader.next();
                    String fid = feature.getID();
                    if( !(source instanceof FeatureLocking)){
                        LOGGER.fine("Lock " + fid +
                                " not supported by data store (authID:"
                                + fLock.getAuthorization() + ")");
                        lockFailedFids.add(fid);
                    }
                    else {
                        Filter fidFilter = filterFactory.createFidFilter(fid);

                        //DEFQuery is just some indirection, should be in the locking interface.
                        //int numberLocked = ((DEFQueryFeatureLocking)source).lockFeature(feature);
                        //HACK: Query.NO_NAMES isn't working in postgis right now,
                        //so we'll just use all.
                        Query query = new DefaultQuery(
                                meta.getTypeName(), fidFilter,
                                Query.DEFAULT_MAX, Query.ALL_NAMES,
                                curLock.getHandle());
                        int numberLocked = ((FeatureLocking)source).lockFeatures( query );

                        if (numberLocked == 1) {
View Full Code Here

            for (Iterator i = request.getLocks().iterator(); i.hasNext();) {
                LockRequest.Lock curLock = (LockRequest.Lock) i.next();

                String curTypeName = curLock.getFeatureType();

                FeatureTypeInfo meta = catalog.getFeatureTypeInfo(curTypeName);
                FeatureLocking source = (FeatureLocking) meta.getFeatureSource();

                Transaction t = new DefaultTransaction();

                try {
                    t.addAuthorization(featureLock.getAuthorization());
View Full Code Here

        // - if we fail to aquire all the locks we will need to fail and
        //   itterate through the the FeatureSources to release the locks
        //
        GeoServer config = request.getWFS().getGeoServer();
        Data catalog = request.getWFS().getData();
        FeatureTypeInfo meta = null;
        NameSpaceInfo namespace;
        Query query;
        int maxFeatures = request.getMaxFeatures();
        int serverMaxFeatures = config.getMaxFeatures();

        if (maxFeatures > serverMaxFeatures) {
            maxFeatures = serverMaxFeatures;
        }

        Set lockedFids = new HashSet();
        Set lockFailedFids = new HashSet();

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

        try {
            for (Iterator it = request.getQueries().iterator();
                    it.hasNext() && (maxFeatures > 0);) {
                query = (Query) it.next();
                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)) {
View Full Code Here

        //allSameType will throw WfsException if there are types that are not found.
        if (allSameType(requestedTypes, wfsRequest)) {
            //all the requested have the same namespace prefix, so return their
            //schemas.
            FeatureTypeInfo nsInfoType = wfsRequest.getWFS().getData()
                                                   .getFeatureTypeInfo((String) requestedTypes
                    .get(0));

            //all types have same prefix, so just use the first.
            NameSpaceInfo namespace = nsInfoType.getDataStoreInfo()
                                                .getNameSpace();
            String targetNs = namespace.getUri();

            //String targetNs = nsInfoType.getXmlns();
            tempResponse.append(TARGETNS_PREFIX + targetNs + TARGETNS_SUFFIX);
View Full Code Here

            // set the current file
            // print type data for the table object
            curTypeName = requestedTypes.get(i).toString();

            //TypeInfo meta = repository.getFeatureType(curTypeName);
            FeatureTypeInfo meta = gs.getData().getFeatureTypeInfo(curTypeName);

            //curTypeName = meta.getName();
            if (meta == null) {
                throw new WfsException("Feature Type " + curTypeName + " does "
                    + "not exist on this server");
            }

            if (!validTypes.contains(meta)) {

                File schemaFile = meta.getSchemaFile();
                   try {
                       //Hack here, schemaFile should not be null, but it is
                       //when a fType is first created, since we only add the
                       //schemaFile param to dto on a load.  This should be
                       //fixed, maybe even have the schema file persist, or at
                       //the very least be present right after creation.
                       if (schemaFile != null &&
                            schemaFile.exists() && schemaFile.canRead()) {
                           generatedType = writeFile(schemaFile);
                       } else {
                           FeatureType ft2 = meta.getFeatureType();
                           String gType2 = generateFromSchema(ft2);

                            if ((gType2 != null) && (gType2 != "")) {
                                generatedType = gType2;
                            }
View Full Code Here

TOP

Related Classes of org.vfny.geoserver.global.FeatureTypeInfo

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.