Giter Club home page Giter Club logo

jskdata's Introduction

jskdata

A java downloader for GeoNorge Download API , Hoydedata and OGC WFS.

Maven

<repository>
    <id>ECC</id>
    <url>https://ecc-mvn.ams3.digitaloceanspaces.com/releases</url>
</repository>

<dependency>
    <groupId>no.jskdata</groupId>
    <artifactId>jskdata</artifactId>
    <version>1.0.20</version>
</dependency>

Usage

  // download using GeoNorge "NedlastingsAPI" anonymously
  Downloader gndlapi = new GeoNorgeDownloadAPI();
  gndlapi.setFormatNameFilter(n -> n.contains("SOSI"));
  gndlapi.dataset("28c896d0-8a0d-4209-bf31-4931033b1082");
  gndlapi.download((fileName, in) -> { # or implement Receiver
  });
  
  // download using GeoNorge "NedlastingsAPI" with authentication.
  // NB: This requires a special user for HTTP Basic Authentication, not
  // a normal GeoID account.
  Downloader gndlapia = new GeoNorgeDownloadAPI(geonorgeUsername, geonorgePassword);
  gndlapia.setFormatNameFilter(n -> n.contains("SOSI"));
  gndlapia.dataset("6e05aefb-f90e-4c7d-9fb9-299574d0bbf6");
  gndlapia.download((fileName, in) -> { # or implement Receiver
  });

  // download using free and open National Elevation Models from hoydedata.no
  Downloader hoydedata = new Hoydedata();
  hoydedata.setUtmzone("33");
  hoydedata.dataset("DTM50");
  hoydedata.download((fileName,in) -> { # or implement Receiver
  });
  

Test

mvn -Dgeonorge.username=... -Dgeonorge.password=... test

Legal

This is just for examples on how to download from some public sites. It is important for every user to follow every instruction on every web page they download data. So please, make sure to have your agreements in place before downloading anything using this code or similar code.

Thanks

  • @atlefren for skdata that jskdatas KartverketDownload was mostly a java variant of.
  • @jhy for jsoup that jskdata uses for HTML parsing.
  • @bgrotan for adding support for Hoydedata.
  • Google for Gson and Guava.
  • Kartverket.

jskdata's People

Contributors

bgrotan avatar dependabot[bot] avatar halset avatar

Watchers

 avatar  avatar  avatar

Forkers

bgrotan lurajon

jskdata's Issues

Suggestion for a new URLDownloader to support Basic Authentication

@Override
public void download(Receiver receiver) throws IOException {
    for (String url : urls) {
        if (receiver.shouldStop()) {
            return;
        }

        currentDownloadUrl = url;
        URL u = new URL(currentDownloadUrl);
        
        String fileName = url.substring(url.lastIndexOf('/') + 1);
       
        URLConnection urlConnection = u.openConnection();

        if (u.getUserInfo() != null) {
        	String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(u.getUserInfo().getBytes());

            urlConnection.setRequestProperty("Authorization", basicAuth);
        }
       
        receiver.receive(fileName, urlConnection.getInputStream());
        currentDownloadUrl = null;
    }
}

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.