kandi background
Explore Kits

open-location-code | Open Location Code is a library to generate short codes

 by   google Java Version: 1.0.4 License: Apache-2.0

 by   google Java Version: 1.0.4 License: Apache-2.0

Download this library from

kandi X-RAY | open-location-code Summary

open-location-code is a Java library typically used in Manufacturing, Utilities, Aerospace, Defense applications. open-location-code has no bugs, it has no vulnerabilities, it has a Permissive License and it has high support. However open-location-code build file is not available. You can install using 'pip install open-location-code' or download it from GitHub, PyPI.
Codes are made up of a sequence of digits chosen from a set of 20. The digits in the code alternate between latitude and longitude. The first four digits describe a one degree latitude by one degree longitude area, aligned on degrees. Adding two further digits to the code, reduces the area to 1/20th of a degree by 1/20th of a degree within the previous area. And so on - each pair of digits reduces the area to 1/400th of the previous area. As an example, the Parliament Buildings in Nairobi, Kenya are located at 6GCRPR6C+24. 6GCR is the area from 2S 36E to 1S 37E. PR6C+24 is a 14 meter wide by 14 meter high area within 6GCR. A "+" character is used after eight digits, to break the code up into two parts and to distinguish codes from postal codes. There will be locations where a 10 digit code is not sufficiently precise, but refining it by a factor of 20 is i) unnecessarily precise and ii) requires extending the code by two digits. Instead, after 10 digits, the area is divided into a 4x5 grid and a single digit used to identify the grid square. A single grid refinement step reduces the area to approximately 3.5x2.8 meters. Codes can be shortened relative to a location. This reduces the number of digits that must be remembered, by using a location to identify an approximate area, and then generating the nearest matching code. Shortening a code, if possible, will drop four or more digits from the start of the code. The degree to which a code can be shortened depends on the proximity of the reference location. If the reference location is derived from a town or city name, it is dependent on the accuracy of the geocoding service. Although one service may place "Zurich" close to the Google office, another may move it by a hundred meters or more, and this could be enough to prevent the original code being recovered. Rather than a large city size feature to generate the reference location, it is better to use smaller, neighbourhood features, that will not have as much variation in their geocode results. Guidelines for shortening codes are in the [wiki](https://github.com/google/open-location-code/wiki). Recovering shortened codes works by providing the short code and a reference location. This does not need to be the same as the location used to shorten the code, but it does need to be nearby. Shortened codes always include the "+" character so it is simple to compute the missing component.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • open-location-code has a highly active ecosystem.
  • It has 3482 star(s) with 433 fork(s). There are 189 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 46 open issues and 128 have been closed. On average issues are closed in 359 days. There are 11 open pull requests and 0 closed requests.
  • It has a positive sentiment in the developer community.
  • The latest version of open-location-code is 1.0.4
open-location-code Support
Best in #Java
Average in #Java
open-location-code Support
Best in #Java
Average in #Java

quality kandi Quality

  • open-location-code has 0 bugs and 0 code smells.
open-location-code Quality
Best in #Java
Average in #Java
open-location-code Quality
Best in #Java
Average in #Java

securitySecurity

  • open-location-code has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • open-location-code code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
open-location-code Security
Best in #Java
Average in #Java
open-location-code Security
Best in #Java
Average in #Java

license License

  • open-location-code is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
open-location-code License
Best in #Java
Average in #Java
open-location-code License
Best in #Java
Average in #Java

buildReuse

  • open-location-code releases are available to install and integrate.
  • Deployable package is available in PyPI.
  • open-location-code has no build file. You will be need to create the build yourself to build the component from source.
  • open-location-code saves you 3312 person hours of effort in developing the same functionality from scratch.
  • It has 7109 lines of code, 370 functions and 127 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
open-location-code Reuse
Best in #Java
Average in #Java
open-location-code Reuse
Best in #Java
Average in #Java
Top functions reviewed by kandi - BETA

kandi has reviewed open-location-code and discovered the below as its top functions. This is intended to give you an instant insight into open-location-code implemented functionality, and help decide if they suit your requirements.

  • Initializes the UI .
  • Checks if the given code is valid .
  • Parses the given search string and returns it .
  • Initializes the welcome page .
  • Search for an OLC code given a search string .
  • Checks if a location is better than the current location
  • Internal method used to connect to old Places API
  • Returns the direction between the given location and destination code .
  • Handle an intent .
  • Navigate .

open-location-code Key Features

8F+GG is missing six leading characters

6C8F+GG is missing four leading characters

React Leaflet - Draw pluscode areas as a grid

copy iconCopydownload iconDownload
import { useEffect } from 'react';
import L from 'leaflet';
import { useLeafletContext } from '@react-leaflet/core';

const PlusCodeGrid = () => {
  const { layerContainer, map } = useLeafletContext();

  useEffect(() => {
    layerContainer.addLayer(
      L.tileLayer('https://{s}-grid.plus.codes/grid/tms/{z}/{x}/{y}.png', {
        tms: true,
        attribution: 'grid by plus codes',
      }).addTo(map)
    );
  }, []);

  return null;
};

export default PlusCodeGrid;

Community Discussions

Trending Discussions on open-location-code
  • React Leaflet - Draw pluscode areas as a grid
Trending Discussions on open-location-code

QUESTION

React Leaflet - Draw pluscode areas as a grid

Asked 2021-Aug-07 at 15:42

I am trying to figure out a way to draw Pluscodes (OLC) on React Leaflet. I can get it to draw normal grids by extending GridLayer class just fine, but couldn't draw pluscodes accordingly. I am yet to figure out how it works completely.

How can I achieve this? Is GridLayer suitable for this task or should I be looking for something else? Also pluscodes should show higher levels as I zoom in.

https://codesandbox.io/s/pluscode-grid-problem-40fho?file=/src/App.jsx

// Grid.jsx
import { useEffect } from "react";
import L from "leaflet";
import { useLeafletContext } from "@react-leaflet/core";

const PlusCodeGrid = () => {
  const { layerContainer, map } = useLeafletContext();

  const createLeafletElement = () => {
    const Grid = L.GridLayer.extend({
      createTile: function (coords) {
        const tile = L.DomUtil.create("canvas", "leaflet-tile");

        tile.style.outline = "1px solid black";

        return tile;
      }
    });
    return new Grid({ tileSize: 100 });
  };

  useEffect(() => {
    layerContainer.addLayer(createLeafletElement());
  }, []);

  return null;
};

export default PlusCodeGrid;

// App.jsx
import React, { useState } from "react";
import { MapContainer, TileLayer, LayersControl } from "react-leaflet";
import PlusCodeGrid from "./Grid";
import { OpenLocationCode } from "open-location-code";

const getBoundariesFromPluscode = (plusCode) => {
  const geocoder = new OpenLocationCode();
  const { latitudeHi, latitudeLo, longitudeHi, longitudeLo } = geocoder.decode(
    plusCode
  );

  const boundary = [
    [latitudeLo, longitudeLo],
    [latitudeHi, longitudeHi]
  ];

  return boundary;
};

const App = () => {
  const [map, setMap] = useState(null);

  const plusCodeExample = "8FHJJMX2+R8";
  const plusCodeBoundaries = getBoundariesFromPluscode(plusCodeExample);

  console.log(plusCodeBoundaries);

  return (
    <div className="leaflet-container">
      <MapContainer
        className="map-container"
        whenCreated={setMap}
        zoom={15}
        scrollWheelZoom={true}
      >
        <LayersControl>
          <TileLayer url="http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
          <LayersControl.Overlay checked name="Pluscode Grid">
            <PlusCodeGrid />
          </LayersControl.Overlay>
        </LayersControl>
      </MapContainer>
    </div>
  );
};

export default App;

ANSWER

Answered 2021-Aug-07 at 15:42

Unbeliveable, the answer was right there in the page I sourced in the question... Once again I choose to skim through documentations quickly to save few minutes only to lose days in the process.

Anyways, grid.plus.codes provides a grid service for plus codes which can easily be used with React leaflet like so:

import { useEffect } from 'react';
import L from 'leaflet';
import { useLeafletContext } from '@react-leaflet/core';

const PlusCodeGrid = () => {
  const { layerContainer, map } = useLeafletContext();

  useEffect(() => {
    layerContainer.addLayer(
      L.tileLayer('https://{s}-grid.plus.codes/grid/tms/{z}/{x}/{y}.png', {
        tms: true,
        attribution: 'grid by plus codes',
      }).addTo(map)
    );
  }, []);

  return null;
};

export default PlusCodeGrid;

Source https://stackoverflow.com/questions/68682588

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install open-location-code

You can install using 'pip install open-location-code' or download it from GitHub, PyPI.
You can use open-location-code like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the open-location-code component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

Support

[Comparison of existing location encoding systems](https://github.com/google/open-location-code/wiki/Evaluation-of-Location-Encoding-Systems). [Open Location Code definition](https://github.com/google/open-location-code/blob/master/docs/olc_definition.adoc).

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.