Skip to content
Andreas W. Bartels edited this page Mar 18, 2018 · 10 revisions

see Ckan homepage, documentation and github

maven

<dependency>
  <groupId>net.anwiba.spatial</groupId>
  <artifactId>anwiba-spatial-data-ckan</artifactId>
  <version>1.0.126</version>
</dependency>

usage

    ICanceler canceler = ICanceler.DummyCanceler;
    
    IResultProducer<PackageSearchResultResponse> responseProducer = 
        (cancelable, statusCode, statusMessage, contentType, contentEncoding, inputStream) 
        -> new CkanJsonResponseUnmarshallerFactory().create(PackageSearchResultResponse.class).unmarshal(inputStream);

    IObjectRequestExecutorBuilder<PackageSearchResultResponse> builder = new ObjectRequestExecutorBuilderFactory().create();

    try (IObjectRequestExecutor<PackageSearchResultResponse> requestExecutor = builder.setResultProducer(responseProducer).build()) {
      
      IRequest request = PackageRequestBuilder
          .search("http://www.europeandataportal.eu/data/en/api")
          .query("water")
          .resourceFormat("geojson")
          .resourceFormat("GEOJSON")
          .resourceFormat("GeoJSON")
          .start(20)
          .rows(10)
          .build();
      
       PackageSearchResultResponse response = requestExecutor.execute(canceler, request);
     
        if (!response.isSuccess()) {
          throw new IOException(response.getError().getMessage());
        }
        
        final PackageSearchResult packageSearchResult = response.getResult();
        final Dataset[] results = packageSearchResult.getResults();

      }

Clone this wiki locally