Giter Site home page Giter Site logo

CSV Array Format about elasticgeo HOT 3 OPEN

ngageoint avatar ngageoint commented on June 3, 2024
CSV Array Format

from elasticgeo.

Comments (3)

dclemenzi avatar dclemenzi commented on June 3, 2024

Not a great solution but for now to get us pass this issue we decided to implement a fix in our post processing when converting the feature into a rowset.

    @Override
    public Object[] next()
    {
        Feature feature = featureIterator.next();

        Object[] row = new Object[properties.size()];

        for (int i = 0; i < properties.size(); i++)
        {
            Object value = feature.getProperty(properties.get(i)).getValue();

            if (value instanceof ArrayList)
            {
                value = StringUtils.join((ArrayList) value, ",");
            }
            else if (value instanceof String && ((String) value).startsWith("[") && ((String) value).endsWith("]"))
            {
                value = StringUtils.join(new JSONArray((String) value).iterator(), ",");
            }

            row[i] = value;
        }

        return row;
    }

One thing to point out when we disable the CSV all of or numeric arrays come back as ArrayList but our String arrays come back as String. Which is why we needed to add the 'else if' portion. Maybe this is a result of how we are indexing the data within ElasticSearch?

from elasticgeo.

sjudeng avatar sjudeng commented on June 3, 2024

Yeah array handling for CSV/GML output has gone through a few iterations in the plugin and the current implementation is still not ideal. Originally array encoding was implemented as a string-join but that caused errors for numeric arrays when outputting GML (and maybe CSV), as I think you've encountered. Let me know if you think you have an approach that would make more sense on the plugin-side for this.

The default (non-CSV) encoding will return the actual array and is suitable for GeoJSON output if you can consume that. This could also be used in the case where you're programmatically accessing features as you'll get the property back as an array directly.

from elasticgeo.

dclemenzi avatar dclemenzi commented on June 3, 2024

Yeah the non-CSV encoding is actually preferred. We need CSV for now so our code is consistent when switching between databases. At some point we should probably make the switch. The change on our side is sufficient to get our ITs passing.

from elasticgeo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.