Giter VIP home page Giter VIP logo

mgrs's People

Contributors

davidallsopp avatar dwyerk avatar ehildy avatar endeav0r avatar garnertb avatar hobu avatar jwilges avatar nhatbui avatar rguerra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mgrs's Issues

Not getting correct lat lon

Hi, I'm getting a wrong Lat Lon for this MGRS "04QEJ 97987 90670".

The correct lat/lon is "21.61643, -158.05325", but I'm getting

"20.79987937710965, -158.99999999999997"

Is there something that I am missing?

the installer will only work on python 3.5 32 bit unless the following is fixed

in core.py, line 21, you have the following:
rt = ctypes.PyDLL('libmgrs.cp35-win32.pyd')

this failed on my python 3.6 32 bit. I ended up changing it to this to get it to work:
rt = ctypes.PyDLL('libmgrs.cp36-win32.pyd')

The file itself is located in:
\Lib\site-packages\libmgrs.cp36-win32.pyd

I figure there should be some code that generates the libmgrs pyd file name based on the version of python installed and if it's 32 bit vs 64 bit. I don't know how to do this, but I figured I'd post this here incase someone knows how to and is willing to do so.

dmstodd gives wrong results when degrees has 3 digits

When the degrees of longitude reach 3 digits, the dmstodd() method gives incorrect results because the digits representing the minutes are extracted using a 2-character offset relative to the start of the string.

>>> import mgrs
>>> m = mgrs.MGRS()
>>> m.dmstodd("110000N")
11.0
>>> m.dmstodd("110000E")
11.0
>>> m.dmstodd("1110000E")
112.66666666666667
>>> m.dmstodd("1110000.00E")
112.66666666666667

This can be fixed by changing [2:-2] to [-4:-2] in two places in dmstodd() so that the two digits representing the minutes are extracted relative to the end of the string, not the beginning

Is there a required ctype?

`
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import mgrs
Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\ArcGISx6410.6\lib\site-packages\mgrs_init_.py", line 1, in
from . core import rt
File "C:\Python27\ArcGISx6410.6\lib\site-packages\mgrs\core.py", line 30, in
rt = ctypes.PyDLL(platform)
File "C:\Python27\ArcGISx6410.6\lib\ctypes_init_.py", line 366, in init
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found
`

PyPI install fails (probably due to missing file)

On an Oracle Enterprise Linux 6.1 box:

(production)[gridusr@rsgisvmw01 GRiD]$ pip install mgrs
Downloading/unpacking mgrs
  Downloading mgrs-1.0.tar.gz
  Running setup.py egg_info for package mgrs
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/home/gridusr/GRiD/virtualenv/production/build/mgrs/setup.py", line 28, in <module>
        readme_text = file('./README.rst', 'rb').read()
    IOError: [Errno 2] No such file or directory: './README.rst'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "/home/gridusr/GRiD/virtualenv/production/build/mgrs/setup.py", line 28, in <module>

    readme_text = file('./README.rst', 'rb').read()

IOError: [Errno 2] No such file or directory: './README.rst'

----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /home/gridusr/.pip/pip.log
(production)[gridusr@rsgisvmw01 GRiD]$

PyInstaller error: mgrs.core.MGRSError: Unable to load libmgrs.cp37-win_amd64.pyd

I see other people are using windows and pyinstaller but I have not been able to resolve this issue. I installed mgrs into my venv and I'm trying to use pyinstaller to create an .exe. When I run the exe I get the following error:

mgrs.core.MGRSError: Unable to load libmgrs.cp37-win_amd64.pyd

I am using mgrs v1.4.2 and pyinstaller v4.2. I'm hoping someone has a solution for me. I tried the solution @uetacog proposed in issue #32 with no luck.

WINDOWS: wheel package must be installed

If wheel is not installed the following in core.py silently fails, the DLL load fails.
Wheel solves the issue:

    libname = 'libmgrs'
    try:
        import wheel.pep425tags
        name = wheel.pep425tags.get_abbr_impl() + \
               wheel.pep425tags.get_impl_ver() + \
               '-' + wheel.pep425tags.get_platform()
        return libname + '.' + name + '.pyd'
    except ImportError:
        return libname + '.pyd'

Unable to load libmgrs.pyd error

Hello,

I have installed the library by pip (Windows 10, Python 3.8.2) and when I try to import mgrs, I see the following error:

>>> import mgrs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\repos\hilla-deep-matching\env\lib\site-packages\mgrs\__init__.py", line 1, in <module>
    from . import core
  File "C:\repos\hilla-deep-matching\env\lib\site-packages\mgrs\core.py", line 74, in <module>
    raise MGRSError("Unable to load %s" % lib_name)
mgrs.core.MGRSError: Unable to load libmgrs.pyd

Could you please advise which library/dependency I might be missing?

Error converting 41RPR323901

m.toLatLon('41RPR323901')
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/mgrs-1.3.1-py2.7-linux-x86_64.egg/mgrs/init.py", line 98, in toLatLon
core.rt.Convert_MGRS_To_Geodetic( c, plat, plon)
File "/usr/local/lib/python2.7/dist-packages/mgrs-1.3.1-py2.7-linux-x86_64.egg/mgrs/core.py", line 65, in check_error
raise RTreeError(msg)
mgrs.core.RTreeError: Error in "Convert_MGRS_To_Geodetic": MGRS Errors

Using with pyinstaller

I wanted to leave a note in case anyone gets caught where I was, or I forget what I did.

When using pyinstaller to package something including mgrs, you need to explicitly include the .so file as pyinstaller will not include it.

pyinstaller <your options> --add-data=libmgrs.cpython-36m-x86_64-linux-gnu.so:. <name of script>

  1. Notice it is .so : . You are telling it to put the so at the top level
  2. The .so is in your site-packages location on ubuntu usually around ~/.local/lib/<python version>/site-packages/

MGRSToUTM only gets zone

Thank you for creating and maintaining this library. It's been very useful and easy to use.

The MGRSToUTM method is not working correctly for me. I've had success using the rest of the library, but converting from MGRS to UTM only seems to find the zone.

I am using mgrs 1.3.7 on an Anaconda distribution of Python 3.7. Thanks!

from mgrs import MGRS

convert = MGRS()
coords = "15SWC8081751205".encode('utf-8')

convert.toLatLon(coords)
>>> (38.40542615377341, -92.07439526029498)

convert.MGRSToUTM(coords)
>>>  (15,)

convert.UTMToMGRS(15,'N'.encode('utf-8'),580817,4251205)
>>> b'15SWC8081751205'

Feature Request: Vector-support

I haven't looked much into the bindings of the library, but I've noticed a significant overhead when processing a vector of multiple coordinates. Is it possible for the API to support lists and have the bindings consume them efficiently to increase performance?

Install on Windows 7 x64 with Python 2.7 x64

I'm trying to build and install this module on Windows 7 x64 with Python 2.7 x64.

I installed setuptools (https://pypi.python.org/pypi/setuptools)

From the visual studio 2008 command prompt I ran:

C:\Users\andy\Downloads\mgrs-master>C:\Python27\python.exe setup.py install

Which did this:

running install
running bdist_egg
running egg_info
writing requirements to mgrs.egg-info\requires.txt
writing mgrs.egg-info\PKG-INFO
writing top-level names to mgrs.egg-info\top_level.txt
writing dependency_links to mgrs.egg-info\dependency_links.txt
reading manifest file 'mgrs.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'mgrs.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
copying mgrs\core.py -> build\lib.win-amd64-2.7\mgrs
copying mgrs\__init__.py -> build\lib.win-amd64-2.7\mgrs
running build_ext
creating build\bdist.win-amd64
creating build\bdist.win-amd64\egg
copying build\lib.win-amd64-2.7\libmgrs.dll -> build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\mgrs
copying build\lib.win-amd64-2.7\mgrs\core.py -> build\bdist.win-amd64\egg\mgrs
copying build\lib.win-amd64-2.7\mgrs\__init__.py -> build\bdist.win-amd64\egg\mgrs
byte-compiling build\bdist.win-amd64\egg\mgrs\core.py to core.pyc
byte-compiling build\bdist.win-amd64\egg\mgrs\__init__.py to __init__.pyc
creating build\bdist.win-amd64\egg\EGG-INFO
copying mgrs.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying mgrs.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying mgrs.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO

copying mgrs.egg-info\not-zip-safe -> build\bdist.win-amd64\egg\EGG-INFO
copying mgrs.egg-info\requires.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying mgrs.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
writing build\bdist.win-amd64\egg\EGG-INFO\native_libs.txt
creating dist
creating 'dist\mgrs-1.1.0-py2.7-win-amd64.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing mgrs-1.1.0-py2.7-win-amd64.egg
creating c:\python27\lib\site-packages\mgrs-1.1.0-py2.7-win-amd64.egg
Extracting mgrs-1.1.0-py2.7-win-amd64.egg to c:\python27\lib\site-packages
Adding mgrs 1.1.0 to easy-install.pth file

Installed c:\python27\lib\site-packages\mgrs-1.1.0-py2.7-win-amd64.egg
Processing dependencies for mgrs==1.1.0
Searching for setuptools==0.6c11
Best match: setuptools 0.6c11
Processing setuptools-0.6c11-py2.7.egg
setuptools 0.6c11 is already the active version in easy-install.pth
Installing easy_install-script.py script to C:\Python27\Scripts
Installing easy_install.exe script to C:\Python27\Scripts
Installing easy_install.exe.manifest script to C:\Python27\Scripts
Installing easy_install-2.7-script.py script to C:\Python27\Scripts
Installing easy_install-2.7.exe script to C:\Python27\Scripts
Installing easy_install-2.7.exe.manifest script to C:\Python27\Scripts

Using c:\python27\lib\site-packages\setuptools-0.6c11-py2.7.egg
Finished processing dependencies for mgrs==1.1.0

But from IDLE when I try to import MGRS I get:

Traceback (most recent call last):
  File "", line 1, in 
    import mgrs
  File "C:\Python27\lib\site-packages\mgrs-1.1.0-py2.7-win-amd64.egg\mgrs\__init__.py", line 1, in 
    from core import rt
  File "C:\Python27\lib\site-packages\mgrs-1.1.0-py2.7-win-amd64.egg\mgrs\core.py", line 18, in 
    rt = ctypes.PyDLL(lib_name)
  File "C:\Python27\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

Calling functions individually

I am attempting to use .toLatLon()
import mgrs m=mgrs.MGRS() m.toLatLon('some MGRS')

but get a tree error:
--RTreeError: Error in "Convert_MGRS_To_Geodetic": MGRS Errors: String Error --

Am i doing something incorrect? When i run it with the Lat/Lon variables, then .toMGRS(); it works fine. Without it, doing it all together as in the example, it provides tree errors.

MacOS Compiling issue

Trying to get mgrs up and running on my mac. Get the following message.
(MacOS 10.13.6)


car-work:~ car$ pip install mgrs
Collecting mgrs
Using cached https://files.pythonhosted.org/packages/1d/49/7abb4403bd44971fa5b75e9deb904ada7c545660dc0704ea79c776d59c49/mgrs-1.3.5.zip
Requirement already satisfied: setuptools in ./anaconda3/lib/python3.6/site-packages (from mgrs) (39.1.0)
Requirement already satisfied: wheel in ./anaconda3/lib/python3.6/site-packages (from mgrs) (0.31.1)
Building wheels for collected packages: mgrs
Running setup.py bdist_wheel for mgrs ... error
Complete output from command /Users/car/anaconda3/bin/python -u -c "import setuptools, tokenize;file='/private/var/folders/8t/5gv3jn288xl05q006s6ffnzh0000gn/T/pip-install-f3fhby_a/mgrs/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /private/var/folders/8t/5gv3jn288xl05q006s6ffnzh0000gn/T/pip-wheel-43jui_tm --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.7-x86_64-3.6
creating build/lib.macosx-10.7-x86_64-3.6/mgrs
copying mgrs/init.py -> build/lib.macosx-10.7-x86_64-3.6/mgrs
copying mgrs/core.py -> build/lib.macosx-10.7-x86_64-3.6/mgrs
running build_ext
sh: line 1: 51479 Segmentation fault: 11 'gcc' --version 2> /dev/null > '/var/folders/8t/5gv3jn288xl05q006s6ffnzh0000gn/T/tmpbr13cdza'
building 'libmgrs' extension
creating build/temp.macosx-10.7-x86_64-3.6
creating build/temp.macosx-10.7-x86_64-3.6/libmgrs
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/car/anaconda3/include -arch x86_64 -I/Users/car/anaconda3/include -arch x86_64 -I./libmgrs -I/Users/car/anaconda3/include/python3.6m -c libmgrs/mgrs.c -o build/temp.macosx-10.7-x86_64-3.6/libmgrs/mgrs.o
gcc: error: x86_64: No such file or directory
gcc: error: x86_64: No such file or directory
gcc: error: unrecognized option ‘-arch’
gcc: error: unrecognized option ‘-arch’
error: command 'gcc' failed with exit status 1


Failed building wheel for mgrs
Running setup.py clean for mgrs
Failed to build mgrs
Installing collected packages: mgrs
Running setup.py install for mgrs ... error
Complete output from command /Users/car/anaconda3/bin/python -u -c "import setuptools, tokenize;file='/private/var/folders/8t/5gv3jn288xl05q006s6ffnzh0000gn/T/pip-install-f3fhby_a/mgrs/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /private/var/folders/8t/5gv3jn288xl05q006s6ffnzh0000gn/T/pip-record-wabximyx/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.7-x86_64-3.6
creating build/lib.macosx-10.7-x86_64-3.6/mgrs
copying mgrs/init.py -> build/lib.macosx-10.7-x86_64-3.6/mgrs
copying mgrs/core.py -> build/lib.macosx-10.7-x86_64-3.6/mgrs
running build_ext
sh: line 1: 51500 Segmentation fault: 11 'gcc' --version 2> /dev/null > '/var/folders/8t/5gv3jn288xl05q006s6ffnzh0000gn/T/tmp5afzv33o'
building 'libmgrs' extension
creating build/temp.macosx-10.7-x86_64-3.6
creating build/temp.macosx-10.7-x86_64-3.6/libmgrs
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/car/anaconda3/include -arch x86_64 -I/Users/car/anaconda3/include -arch x86_64 -I./libmgrs -I/Users/car/anaconda3/include/python3.6m -c libmgrs/mgrs.c -o build/temp.macosx-10.7-x86_64-3.6/libmgrs/mgrs.o
gcc: error: x86_64: No such file or directory
gcc: error: x86_64: No such file or directory
gcc: error: unrecognized option ‘-arch’
gcc: error: unrecognized option ‘-arch’
error: command 'gcc' failed with exit status 1

----------------------------------------

Command "/Users/car/anaconda3/bin/python -u -c "import setuptools, tokenize;file='/private/var/folders/8t/5gv3jn288xl05q006s6ffnzh0000gn/T/pip-install-f3fhby_a/mgrs/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /private/var/folders/8t/5gv3jn288xl05q006s6ffnzh0000gn/T/pip-record-wabximyx/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/8t/5gv3jn288xl05q006s6ffnzh0000gn/T/pip-install-f3fhby_a/mgrs/
car-work:~ car$

Wheels for 3.11 & 3.12

Will there be wheels built for 3.11 & 3.12? Windows users on either of those versions will be running into issues with the tar.gz installation route.

Wrong tile for a specific point

I have used the mgrs library to get the tile for this point :

Lat = 39.9770
Lon = 116.3810

I get this tile:

50SMK4714425387

this does not correspond to any exsisting Sentinel2 tile. It should be 50TMK

Windows Package libmgrs.cp38-win_amd64.pyd Not Found

I recently ran this on my Windows machine. When I ran it on a virtual environment in Anaconda, I had no problem, just had to revert the admin-root edit that was raised in a previous issue to get it working. However outside of the virtualenv, using Visual Studio I encounter this error every time I try to import mgrs:

FileNotFoundError: Could not find module 'libmgrs.cp38-win_amd64.pyd'. Try using the full path with constructor syntax.

Any idea what this could be linked to? I haven't had any success so far.

On pypy, downloads for windows get in the way

mgrs 1.0.1 on pypy includes several windows downloads, including mgrs-1.0.1.win32.zip. When I run pip install mgrs on my Mac OSX, pip fetches the windows .zip instead of the tarball and subsequently fails:

Downloading/unpacking mgrs
  Downloading mgrs-1.0.1.win32.zip
  Running setup.py egg_info for package mgrs
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
    IOError: [Errno 2] No such file or directory: '/Users/peteg/.virtualenvs/clean/build/mgrs/setup.py'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 14, in <module>

IOError: [Errno 2] No such file or directory: '/Users/peteg/.virtualenvs/clean/build/mgrs/setup.py'

get_platform() missing 1 required positional argument: 'archive_root'

I am receiving an issue since wheel updated. I'm getting an error at

.env\lib\site-packages\mgrs\core.py in get_windows_platform_name
line 18 '-' + wheel.pep425tags.get_platform()

It looks like wheel now expects archive_root to be provided to wheel.pep425tags.get_platform().

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.