All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.ext.legacygraphqlapi.datafetchers.LegacyGraphQLStopGeometriesImpl Maven / Gradle / Ivy

package org.opentripplanner.ext.legacygraphqlapi.datafetchers;

import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import java.util.ArrayList;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryCollection;
import org.opentripplanner.ext.legacygraphqlapi.generated.LegacyGraphQLDataFetchers.LegacyGraphQLStopGeometries;
import org.opentripplanner.util.PolylineEncoder;
import org.opentripplanner.util.model.EncodedPolylineBean;

public class LegacyGraphQLStopGeometriesImpl implements LegacyGraphQLStopGeometries {

    @Override
    public DataFetcher geoJson() {
        return this::getSource;
    }

    @Override
    public DataFetcher> googleEncoded() {
        return env -> {
            Geometry geometries = getSource(env);
            ArrayList output = new ArrayList<>();

            for (int i = 0; i < geometries.getNumGeometries(); i++) {
                output.add(geometries.getGeometryN(i));
            }
            return output;
        };
    }

    private Geometry getSource(DataFetchingEnvironment environment) {
        return environment.getSource();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy