{"_id":"@cgcs2000/geo-viewport","_rev":"1-ddf50b3dd5e1b0f95951ca3b10ec2549","name":"@cgcs2000/geo-viewport","dist-tags":{"latest":"0.4.0"},"versions":{"0.4.0":{"license":"BSD-2-Clause","name":"@cgcs2000/geo-viewport","repository":{"url":"git@github.com:cgcs2000/geo-viewport.git","type":"git"},"author":{"name":"Tom MacWright"},"bugs":{"url":"https://github.com/cgcs2000/geo-viewport/issues"},"version":"0.4.0","dependencies":{"@cgcs2000/sphericalmercator":"~1.1.0"},"scripts":{"test":"tap test/*.js","build":"browserify -s geoViewport index.js | uglifyjs -c > geo-viewport.js"},"keywords":["geographic","viewport","zoom","scale"],"devDependencies":{"browserify":"^13.0.0","uglify-js":"^2.6.2","tap":"^5.7.0"},"main":"index.js","homepage":"https://github.com/cgcs2000/geo-viewport","description":"convert between viewports and extents","licenseText":"BSD 2-Clause License\n\nCopyright (c) 2016, Mapbox\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this\n  list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice,\n  this list of conditions and the following disclaimer in the documentation\n  and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","_id":"@cgcs2000/geo-viewport@0.4.0","dist":{"shasum":"678049550c9025fe8978c136908632a25700c242","integrity":"sha512-Qjwu25uVnxl18ylKDtfG6Y/aHZzdEDIQecH5Zut+53W79o1hOf4n6wVIBzQ0fzYBRHXnn3b9q7RqEpgmz+3oLw==","tarball":"https://registry.npmjs.org/@cgcs2000/geo-viewport/-/geo-viewport-0.4.0.tgz","fileCount":17,"unpackedSize":172058,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcgTTmCRA9TVsSAnZWagAAxy8P/3CmODokt+iUuPdP5xDy\nO2auN8YmUWnolBAiGJeOk59HAImjWXIa1Xfoa1HqUm1GnWLdUlKk1YoPcjcy\n8ZjrmaRrm+MkJ32PGscd3nQ7KTCxg+TduYju1jwHnzAiU+s26oVjUySE215r\nkxTxSCCEwFzxoKlMAw2WomCKQqdXV75b8OKn8iqTPIwnh0lyDXgy8vg2HsyW\nx0g01ECYs5dWYw9h93tO8uq6x0TWVIyJWu6hAmlVIyYMnp9LQMqIbCC7ehWp\nXYiKVo3ZeqtfLMySAGT49Pu4wY3M9SMNo0wGBFji7AYXqm68d2LXilvupyG6\nU8sjd2cGa7nyZiL0pnrJtox/duNasIlvAQJqR1DoCtrqRW2YvC3PabRfTkbm\nYHiuUmAV45ic1TGMiaHvb1AggJUORcsrL3lpSs7/d2W7SBl2YpZ+JfT1vU06\nlV692eXHc+QW+tVn6FJViE9I58lEYZKq8gNXgDT8s1UJv5dkBA8boH5tWGaE\nQFcI0OQpa3ivVQps4DXWOtvHixkdaIOf+CgL9GWUvaj7mrodcR5f3oSFx1Hu\nGTcMnAIJzHZ86dlV/ygUuNrq+P3VJGeLFBksPjVsP0/jCOxA2tDoRtQnhlUQ\nfsVqw3W2kjXK2XvCGUzi/H5XTaB/qIuYMhD9AQWUnzbi3FxiIOyRQ7LDTiqG\nDFlg\r\n=BR+h\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC6cTG/XOght4LETjR1zlJdjXl9Zl01CryFZyTbwQJF/wIgZlOwxwO5OfOmjUwDoVT5NKBjoaHU0H/RrsDupLr166Q="}]},"maintainers":[{"name":"wanyanyan","email":"wanyanya@126.com"},{"name":"jingsam","email":"jing-sam@qq.com"}],"_npmUser":{"name":"jingsam","email":"jing-sam@qq.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/geo-viewport_0.4.0_1551971558128_0.5655776314741099"},"_hasShrinkwrap":false}},"time":{"created":"2019-03-07T15:12:37.959Z","0.4.0":"2019-03-07T15:12:38.238Z","modified":"2022-04-04T22:25:22.561Z"},"maintainers":[{"name":"wanyanyan","email":"wanyanya@126.com"},{"name":"jingsam","email":"jing-sam@qq.com"}],"description":"convert between viewports and extents","homepage":"https://github.com/cgcs2000/geo-viewport","keywords":["geographic","viewport","zoom","scale"],"repository":{"url":"git@github.com:cgcs2000/geo-viewport.git","type":"git"},"author":{"name":"Tom MacWright"},"bugs":{"url":"https://github.com/cgcs2000/geo-viewport/issues"},"license":"BSD-2-Clause","readme":"[![Build Status](https://travis-ci.org/mapbox/geo-viewport.svg)](https://travis-ci.org/mapbox/geo-viewport)\n\n# geo-viewport\n\n> This repository is a fork of `mapbox/geo-viewport`, but for CGCS200 projection.\n\nTurns bounding boxes / extents into centerpoint & zoom\ncombos for static maps.\n\nWorks in node.js and browsers, via [browserify](http://browserify.org/)\nor a script tag.\n\n## Install\n\n    npm install --save @cgcs2000/geo-viewport\n\nOr use a plugin:\n\n```html\n<script src='//api.tiles.mapbox.com/mapbox.js/plugins/geo-viewport/v0.2.1/geo-viewport.js'></script>\n```\n\nThe script-tag include exports an object called `geoViewport`,\nwith methods `bounds` and `viewport` documented below.\n\n## Example\n\n[Live example with Mapbox Static Map API](https://www.mapbox.com/mapbox.js/example/v1.0.0/static-map-from-bounds-with-geo-viewport/)\n\n### With Node\n\n```js\nvar geoViewport = require('@cgcs2000/geo-viewport');\n\ngeoViewport.viewport([\n    5.668343999999995,\n    45.111511000000014,\n    5.852471999999996,\n    45.26800200000002\n], [640, 480])\n\n// yields\n// {\n//     center: [\n//         5.7604079999999955,\n//         45.189756500000016\n//     ],\n//     zoom: 11\n// }\n```\n\nIn a browser:\n\n```html\n<script src='//api.tiles.mapbox.com/mapbox.js/plugins/geo-viewport/v0.1.1/geo-viewport.js'></script>\n<script>\nvar bounds = geoViewport.viewport([\n    5.668343999999995,\n    45.111511000000014,\n    5.852471999999996,\n    45.26800200000002\n], [640, 480]);\n\nvar center = geoViewport.bounds(\n  [-75.03,\n  35.25],\n  14,\n  [600, 400]);\n\nconsole.log(bounds);\nconsole.log(center);\n</script>\n```\n\n## api\n\n### `viewport(bounds, dimensions, minzoom, maxzoom, tileSize, allowFloat)`\n\nGiven a `WSEN` array of bounds and a `[x, y]` array of pixel dimensions, return a `{ center: [lon, lat], zoom: zoom }` viewport. Use `allowFloat` to retain float values in the output.\n\nExample:\n\n```js\n// first argument is the bounds, and the image is 640x480\ngeoViewport.viewport([\n    5.6683, 45.111, 5.8524, 45.268\n], [640, 480])\n```\n\n### `bounds(viewport, zoom, dimensions, tileSize)`\n\nGiven a centerpoint as `[lon, lat]` or `{ lon, lat }`, a zoom,\nand dimensions as `[x, y]`, return a bounding box.\n\nExample:\n\n```js\ngeoViewport.bounds([-75.03, 35.25], 14, [600, 400])\n```\n\n## tile sizes\n\nBe aware that these calculations are sensitive to tile size. The default size assumed by this library is 256x256px; however, Mapbox Vector Tiles are 512x512px.\n\nFor example, to calculating a bounding box for a classic raster-based 256x256 tile:\n\n```js\ngeoViewport.bounds([-75.03, 35.25], 14, [600, 400], 256)\n\n// since 256 is default, you can omit the tileSize param\ngeoViewport.bounds([-75.03, 35.25], 14, [600, 400])\n```\n\nTo calculate a bounding box for a Mapbox vector tile source, such as an image from the [Mapbox Static Image API](https://www.mapbox.com/api-documentation/#static):\n\n```js\ngeoViewport.bounds([-75.03, 35.25], 14, [600, 400], 512)\n```\n\nThere's a [handy blog post discussing the issue here](https://www.mapbox.com/blog/512px-map-tile).\n","readmeFilename":"README.md"}