Search in sources :

Example 1 with Feature

use of org.opensextant.giscore.events.Feature in project Xponents by OpenSextant.

the class GISDataFormatter method writeGeocodingResult.

/**
     * Implementation of adding info extraction/geocoding restults to GIS outputs.
     */
@Override
public void writeGeocodingResult(ExtractionResult rowdata) {
    boolean error = false;
    log.debug("Adding data for File {} Count={}", rowdata.recordFile, rowdata.matches.size());
    for (TextMatch g : rowdata.matches) {
        if (filterOut(g)) {
            continue;
        }
        // Increment ID
        id++;
        // Only TextMatches that implement the Geocoding interface are
        // allowed here:
        Geocoding geocoding = getGeocoding(g);
        if (geocoding == null) {
            log.debug("Non-geo will be ignored: {}", g);
            continue;
        }
        log.debug("Add {}#{}", id, g);
        try {
            for (Feature row : gisDataModel.buildRows(id, geocoding, g, rowdata.attributes, rowdata)) {
                log.debug("FEATURE: {}", row);
                this.os.write(row);
            }
        } catch (ConfigException fieldErr) {
            if (!error) {
                log.error("OUTPUTTER, ERR=" + fieldErr);
            }
            error = true;
        }
    }
}
Also used : ConfigException(org.opensextant.ConfigException) TextMatch(org.opensextant.extraction.TextMatch) Geocoding(org.opensextant.data.Geocoding) Feature(org.opensextant.giscore.events.Feature)

Example 2 with Feature

use of org.opensextant.giscore.events.Feature in project Xponents by OpenSextant.

the class GISDataModel method buildRows.

/**
     * Builds a GISCore feature array (rows) from a given array of TextMatches; Enrich
     * the features with record-level attributes (columns).  If provided result has .input set, 
     * then conext and other metadata for this match will be pulled from it.  Context is not 
     * pulled at match time, as it is not used by most processing -- it tends to be more 
     * of an output/formatting issue.  And only matches that pass any filters are enriched with 
     * context and other metadaa.
     *
     *
     * @param id
     *            the id
     * @param g
     *            the g
     * @param m
     *            the m
     * @param rowAttributes
     *            the row attributes
     * @param res
     *            the res
     * @return the list
     * @throws ConfigException
     *             schema configuration error
     */
public List<Feature> buildRows(int id, Geocoding g, TextMatch m, Map<String, Object> rowAttributes, ExtractionResult res) throws ConfigException {
    Feature row = new Feature();
    // Administrative settings:
    row.setName(g.getPlaceName());
    row.setSchema(schema.getId());
    row.putData(OpenSextantSchema.SCHEMA_OID, id);
    //
    if (includeOffsets) {
        addOffsets(row, m);
    }
    addPlaceData(row, g);
    addPrecision(row, g);
    if (m.getContext() == null && res.input != null) {
        int len = res.input.buffer.length();
        ResultsUtility.setContextFor(res.input.buffer, m, len);
    }
    addContext(row, m);
    addMatchText(row, m);
    addMatchMethod(row, g.getMethod());
    addAdditionalAttributes(row, rowAttributes);
    if (res.recordFile != null) {
        addFilePaths(row, res.recordFile, res.recordTextFile);
    }
    // this is a list for M x N times
    List<Feature> features = new ArrayList<Feature>();
    features.add(row);
    return features;
}
Also used : ArrayList(java.util.ArrayList) Feature(org.opensextant.giscore.events.Feature) Point(org.opensextant.giscore.geometry.Point)

Aggregations

Feature (org.opensextant.giscore.events.Feature)2 ArrayList (java.util.ArrayList)1 ConfigException (org.opensextant.ConfigException)1 Geocoding (org.opensextant.data.Geocoding)1 TextMatch (org.opensextant.extraction.TextMatch)1 Point (org.opensextant.giscore.geometry.Point)1