Fix European trip return heuristic for weekend location tracking
Adjust European short trip heuristic from >3 days to >1 day to correctly detect when user has returned home from European trips. This fixes the April 29-30, 2023 case where the location incorrectly showed "Sankt Georg, Hamburg" instead of "Bristol" when the user was free (no events scheduled) after the foss-north trip ended on April 27. The previous logic required more than 3 days to pass before assuming return home from European countries, but for short European trips by rail/ferry, users typically return within 1-2 days. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
663dc479c2
commit
ea4980a5d7
6407 changed files with 1072847 additions and 18 deletions
674
node_modules/leaflet.geodesic/LICENSE
generated
vendored
Normal file
674
node_modules/leaflet.geodesic/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
312
node_modules/leaflet.geodesic/README.md
generated
vendored
Normal file
312
node_modules/leaflet.geodesic/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,312 @@
|
|||
# Leaflet.Geodesic
|
||||
[](https://app.travis-ci.com/github/henrythasler/Leaflet.Geodesic) [](https://www.npmjs.com/package/leaflet.geodesic) [](https://coveralls.io/github/henrythasler/Leaflet.Geodesic?branch=master) [](https://sonarcloud.io/dashboard?id=henrythasler_Leaflet.Geodesic)
|
||||
|
||||
Add-on for [Leaflet](http://leafletjs.com/) to draw [geodesic](http://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid) lines and circles. A geodesic line is the shortest path between two given positions on the earth surface. It's based on [Vincenty's formulae](https://en.wikipedia.org/wiki/Vincenty%27s_formulae) implemented by [Chris Veness](https://github.com/chrisveness/geodesy) for highest precision.
|
||||
|
||||
[](https://blog.cyclemap.link/Leaflet.Geodesic/basic-interactive.html)
|
||||
|
||||
[Live Demos and Tutorials](https://blog.cyclemap.link/Leaflet.Geodesic/)
|
||||
|
||||
[Observable-Notebook](https://observablehq.com/@henrythasler/leaflet-geodesic)
|
||||
|
||||
[API-Documentation](https://blog.cyclemap.link/Leaflet.Geodesic/api)
|
||||
|
||||
## Add the plugin to your project
|
||||
|
||||
Leaflet.Geodesic is available via CDN. Add the following snippet to your html-file after you have [included leaflet.js](https://leafletjs.com/examples/quick-start/).
|
||||
|
||||
```html
|
||||
<!-- Make sure you put this AFTER leaflet.js -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/leaflet.geodesic">
|
||||
integrity="see-release-page-for-current-checksum"
|
||||
crossorigin=""></script>
|
||||
```
|
||||
|
||||
Leaflet.Geodesic is available via the following CDNs:
|
||||
|
||||
- [unpkg](https://unpkg.com/browse/leaflet.geodesic/)
|
||||
- [jsDelivr](https://www.jsdelivr.com/package/npm/leaflet.geodesic)
|
||||
- [npmjs](https://www.npmjs.com/package/leaflet.geodesic)
|
||||
|
||||
Add it in your nodejs-project with `npm i leaflet.geodesic`.
|
||||
|
||||
It is good practice, to pin the plug-in to a specific version and use [Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity). Check the [release page](https://github.com/henrythasler/Leaflet.Geodesic/releases) for the latest version, links and checksum. A checksum can by verified with `npm run build`, is stored in `dist/leaflet.geodesic.umd.min.js.sha512` on [jsDelivr](https://www.jsdelivr.com/package/npm/leaflet.geodesic?path=dist) and [unpkg](https://unpkg.com/browse/leaflet.geodesic/dist/leaflet.geodesic.umd.min.js.sha512) and is shown in the [build-log](https://app.travis-ci.com/github/henrythasler/Leaflet.Geodesic/builds) for a tagged version.
|
||||
|
||||
## Basic usage
|
||||
|
||||
- `L.Geodesic` draws geodesic lines between all points of a given line- or multiline-string.
|
||||
- `L.GeodesicCircle` draws a circle with a specific radius around a given point.
|
||||
|
||||
The Objects can be created as follows:
|
||||
|
||||
```JavaScript
|
||||
const geodesicLine = new L.Geodesic().addTo(map); // creates a blank geodesic-line-object and adds it to the map
|
||||
const geodesicCircle = new L.GeodesicCircle().addTo(map); // creates a blank geodesic-circle-object and adds it to the map
|
||||
```
|
||||
|
||||
Alternative method:
|
||||
|
||||
```JavaScript
|
||||
const geodesicLine = L.geodesic().addTo(map); // lower-case, w/o new-keyword
|
||||
const geodesicCircle = L.geodesiccircle().addTo(map); // lower-case, w/o new-keyword
|
||||
```
|
||||
|
||||
Make sure you add the geodesic-object to the map (`.addTo(map)`). It won't display otherwise.
|
||||
|
||||
Each constructor is defined as:
|
||||
```JavaScript
|
||||
Geodesic(latlngs?: L.LatLngExpression[] | L.LatLngExpression[][], options?: GeodesicOptions)
|
||||
GeodesicCircle(center?: L.LatLngExpression, options?: GeodesicOptions)
|
||||
```
|
||||
|
||||
Both classes are extended from [L.Polyline](http://leafletjs.com/reference.html#polyline), so all methods, events and options for `L.Polyline` can be used with `L.Geodesic` and `L.GeodesicCircle` here as well. Any [alt-properties](https://leafletjs.com/reference.html#latlng-l-latlng) given with any points are preserved by `L.Geodesic`.
|
||||
|
||||
## Geodesic Lines
|
||||
|
||||
This draws a line. The geometry (points) to use can be given during creation as:
|
||||
|
||||
### Objects (Literals)
|
||||
|
||||
```JavaScript
|
||||
const Berlin = {lat: 52.5, lng: 13.35};
|
||||
const LosAngeles = {lat: 33.82, lng: -118.38};
|
||||
const geodesic = new L.Geodesic([Berlin, LosAngeles]).addTo(map);
|
||||
```
|
||||
|
||||
### LatLng-Class
|
||||
|
||||
```JavaScript
|
||||
const Berlin = new L.LatLng(52.5, 13.35);
|
||||
const LosAngeles = new L.LatLng(33.82, -118.38);
|
||||
const geodesic = new L.Geodesic([Berlin, LosAngeles]).addTo(map);
|
||||
```
|
||||
|
||||
### Tuples
|
||||
|
||||
```JavaScript
|
||||
const Berlin = [52.5, 13.35];
|
||||
const LosAngeles = [33.82, -118.38];
|
||||
const geodesic = new L.Geodesic([Berlin, LosAngeles]).addTo(map);
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Line-strings
|
||||
|
||||
Multiple consecutive points can be given as an array (linestring):
|
||||
|
||||
```JavaScript
|
||||
const places = [
|
||||
new L.LatLng(52.5, 13.35), // Berlin
|
||||
new L.LatLng(33.82, -118.38), // Los Angeles
|
||||
new L.LatLng(-33.44, -70.71), // Santiago
|
||||
new L.LatLng(-33.94, 18.39), // Capetown
|
||||
];
|
||||
const geodesic = new L.Geodesic(places).addTo(map);
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Multi-line-strings
|
||||
|
||||
Multiple independent linestrings can be defined as a 2-dimensional array of points:
|
||||
|
||||
```JavaScript
|
||||
const places = [
|
||||
[ // 1st line
|
||||
new L.LatLng(52.5, 13.35), // Berlin
|
||||
new L.LatLng(33.82, -118.38), // Los Angeles
|
||||
],
|
||||
[ // 2nd line
|
||||
new L.LatLng(-33.44, -70.71), // Santiago
|
||||
new L.LatLng(-33.94, 18.39), // Capetown
|
||||
]
|
||||
];
|
||||
const geodesic = new L.Geodesic(places).addTo(map);
|
||||
```
|
||||
|
||||

|
||||
|
||||
### GeoJSON-Support
|
||||
|
||||
GeoJSON-data can be used to create geodesic lines with the `fromGeoJson()` method:
|
||||
|
||||
```JavaScript
|
||||
const geojson = {
|
||||
"type": "LineString",
|
||||
"coordinates": [
|
||||
[13.35, 52.5], [-122.33, 47.56], [18.39, -33.94], [116.39, 39.92], [13.35, 52.5]
|
||||
]
|
||||
};
|
||||
const geodesic = new L.Geodesic().addTo(map);
|
||||
geodesic.fromGeoJson(geojson);
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Updating the geometry
|
||||
|
||||
#### Set new geometry
|
||||
|
||||
The Geodesic-Class provides a `setLatLngs()`-Method, that can be used to update the geometry of an existing `L.Geodesic`-object:
|
||||
|
||||
```Javascript
|
||||
const geodesic = new L.Geodesic().addTo(map); // add empty object to the map
|
||||
|
||||
const Berlin = new L.LatLng(52.5, 13.35);
|
||||
const LosAngeles = new L.LatLng(33.82, -118.38);
|
||||
|
||||
geodesic.setLatLngs([Berlin, LosAngeles]) // update in-place
|
||||
```
|
||||
|
||||
The `setLatLngs()`-Method accepts the same types (Literal, Tuple, LatLang-Class, Linstring, Multilinestring) as the L.Geodesic-constructor itself. Please refer to the section about geodesic circles below, on how to update a circle geometry.
|
||||
|
||||
#### Delete geometry
|
||||
|
||||
Delete the existing geometry by setting an empty array `geodesic.setLatLngs([])`.
|
||||
|
||||
#### adding points
|
||||
|
||||
Points can be added to existing geodesic lines with `addLatLng()`:
|
||||
|
||||
```Javascript
|
||||
const Berlin = new L.LatLng(52.5, 13.35);
|
||||
const LosAngeles = new L.LatLng(33.82, -118.38);
|
||||
const Beijing = new L.LatLng(39.92, 116.39);
|
||||
|
||||
const geodesic = new L.Geodesic([Berlin, LosAngeles]).addTo(map);
|
||||
geodesic.addLatLng(Beijing); // results in [[Berlin, LosAngeles, Beijing]
|
||||
```
|
||||
|
||||
The new point will always be added to the last linestring of a multiline. You can define a specific linestring to add to by reading the `points` property before and hand over a specific linestring as second parameter:
|
||||
|
||||
```Javascript
|
||||
const Berlin = new L.LatLng(52.5, 13.35);
|
||||
const LosAngeles = new L.LatLng(33.82, -118.38);
|
||||
const Beijing = new L.LatLng(39.92, 116.39 );
|
||||
const Capetown = new L.LatLng(-33.94, 18.39 );
|
||||
const Santiago = new L.LatLng(-33.44, -70.71);
|
||||
|
||||
const geodesic = new L.Geodesic([[Berlin, LosAngeles], [Santiago, Capetown]]).addTo(map);
|
||||
geodesic.addLatLng(Beijing, geodesic.points[0]); // results in [[Berlin, LosAngeles, Beijing], [Santiago, Capetown]]
|
||||
```
|
||||
|
||||
### Drawing over the antimeridian
|
||||
|
||||
In some cases it is required to draw over the antimeridian (dateline) to show a continuous path. This is possible by setting the `wrap`-option to false. Leaflet.Geodesic will make sure to shift the individual points to draw a continuous line, even if the coordinates are not properly aligned to a map section. See [interactive example](https://blog.cyclemap.link/Leaflet.Geodesic/multiline-nosplit.html)
|
||||
|
||||
```Javascript
|
||||
const Berlin = new L.LatLng(52.5, 13.35);
|
||||
const LosAngeles = new L.LatLng(33.82, -118.38);
|
||||
const Capetown = new L.LatLng(-33.94, 18.39 );
|
||||
const Santiago = new L.LatLng(-33.44, -70.71);
|
||||
const Tokyo = new L.LatLng(35.47, 139.15 + 360); // these points are in another map section
|
||||
const Sydney = new L.LatLng(-33.91, 151.08 + 10 * 360); // but will get shifted accordingly
|
||||
|
||||
const geodesic = L.geodesic(
|
||||
[ Santiago, Tokyo, Capetown, Sydney, LosAngeles, Berlin],
|
||||
{ wrap: false
|
||||
}).addTo(map);
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Line Options
|
||||
All options defined for [Polyline](http://leafletjs.com/reference.html#polyline) and [Path](https://leafletjs.com/reference.html#path) for can be used Leaflet.Geodesic.
|
||||
|
||||
The most important options are:
|
||||
|
||||
Option | Type | Default | Description
|
||||
---|---|---|---
|
||||
`color` | `String` | "#3388ff" | Stroke color
|
||||
`weight` | `Number` | 3 | Stroke width in pixels
|
||||
`opacity` | `Number` | 1.0 | Stroke opacity (0=transparent, 1=opaque)
|
||||
`steps` | `Number` | 3 | Level of detail (vertices = 1+2**(steps+1)) for the geodesic line. More steps result in a smoother line. Range: 0..8
|
||||
`wrap` | `Boolean` | true | Wrap geodesic line at antimeridian. Set to `false`, to draw a line over the antimeridian. See [no-wrap demo](https://blog.cyclemap.link/Leaflet.Geodesic/nowrap-interactive.html) for example.
|
||||
|
||||
Example:
|
||||
|
||||
```Javascript
|
||||
const Berlin = new L.LatLng(52.5, 13.35);
|
||||
const LosAngeles = new L.LatLng(33.82, -118.38);
|
||||
const options = {
|
||||
weight: 20,
|
||||
opacity: 0.5,
|
||||
color: 'red',
|
||||
};
|
||||
const geodesic = new L.Geodesic([Berlin, LosAngeles], options).addTo(map);
|
||||
```
|
||||
|
||||

|
||||
|
||||
## Geodesic Circles
|
||||
|
||||
Circles can be added with another class called `L.GeodesicCircle` as follows:
|
||||
|
||||
```Javascript
|
||||
const Seattle = new L.LatLng(47.56, -122.33);
|
||||
const geodesiccircle = new L.GeodesicCircle(Seattle, {
|
||||
radius: 3000*1000, // 3000km in meters
|
||||
}).addTo(map);
|
||||
```
|
||||
|
||||

|
||||
|
||||
The geometry of a circle can be updated with the following methods:
|
||||
|
||||
- `setLatLng(latlng: L.LatLngExpression)` - set a new center
|
||||
- `setRadius(radius: number)` - update the radius
|
||||
|
||||
Handling of **filled** circles crossing the antimeridian (wrapping) is not yet supported. Set `fill: false` in these cases to avoid display artefacts.
|
||||
|
||||
### Circle Options
|
||||
|
||||
Option | Type | Default | Description
|
||||
---|---|---|---
|
||||
`radius` | `Number` | 1000*1000 | Radius in **meters**
|
||||
`steps` | `Number` | 24 | Number of segments that are used to approximate the circle.
|
||||
`fill` | `boolean` | true | Draws a filled circle.
|
||||
`color` | `String` | "#3388ff" | Stroke color
|
||||
`weight` | `Number` | 3 | Stroke width in pixels
|
||||
`opacity` | `Number` | 1.0 | Stroke opacity (0=transparent, 1=opaque)
|
||||
|
||||
Please refer to the options for [Polyline](http://leafletjs.com/reference.html#polyline) and [Path](https://leafletjs.com/reference.html#path) for additional settings.
|
||||
|
||||
## Statistics
|
||||
|
||||
The `L.Geodesic` and `L.GeodesicCircle`-class provide a `statistics`-Object with the following properties:
|
||||
|
||||
Property | Type | Description
|
||||
---|---|---
|
||||
`totalDistance` | `Number` | The total distance of all geodesic lines in meters. (Circumfence for `L.GeodesicCircle`)
|
||||
`distanceArray` | `Number[]` | The distance for each separate linestring in meters
|
||||
`points` | `Number` | Number of points that were given on creation or with `setLatLngs()`
|
||||
`vertices` | `Number` | Number of vertices of all geodesic lines that were calculated
|
||||
|
||||
## Distance Calculation
|
||||
|
||||
The `L.Geodesic` provides a `distance`-function to calculate the precise distance between two points:
|
||||
|
||||
```Javascript
|
||||
const Berlin = new L.LatLng(52.5, 13.35);
|
||||
const Beijing = new L.LatLng(39.92, 116.39);
|
||||
|
||||
const line = new L.Geodesic();
|
||||
const distance = line.distance(Berlin, Beijing);
|
||||
console.log(`${Math.floor(distance/1000)} km`) // prints: 7379 km
|
||||
```
|
||||
|
||||
The `L.GeodesicCircle`-class provides a `distanceTo`-function to calculate the distance between the current center and any given point:
|
||||
|
||||
```Javascript
|
||||
const Berlin = new L.LatLng(52.5, 13.35);
|
||||
const Beijing = new L.LatLng(39.92, 116.39);
|
||||
|
||||
const circle = new L.GeodesicCircle(Berlin);
|
||||
const distance = circle.distanceTo(Beijing);
|
||||
console.log(`${Math.floor(distance/1000)} km`) // prints: 7379 km
|
||||
```
|
||||
|
||||
## Scientific background
|
||||
|
||||
All calculations are based on the [WGS84-Ellipsoid](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84) (EPSG:4326) using [Vincenty's formulae](https://en.wikipedia.org/wiki/Vincenty%27s_formulae). This method leads to very precise calculations but may fail for some corner-cases (e.g. [Antipodes](https://en.wikipedia.org/wiki/Antipodes)). I use some workarounds to mitigate these convergence errors. This may lead to reduced precision (a.k.a. slightly wrong results) in these cases. This is good enough for a web mapping application but you shouldn't plan a space mission based on this data. OMG, this section has just become a disclaimer...
|
||||
270
node_modules/leaflet.geodesic/dist/leaflet.geodesic.d.ts
generated
vendored
Normal file
270
node_modules/leaflet.geodesic/dist/leaflet.geodesic.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,270 @@
|
|||
/*! leaflet.geodesic 2.7.1 - (c) Henry Thasler - https://github.com/henrythasler/Leaflet.Geodesic#readme */
|
||||
import * as L from 'leaflet';
|
||||
|
||||
interface GeodesicOptions extends L.PolylineOptions {
|
||||
wrap?: boolean;
|
||||
steps?: number;
|
||||
radius?: number;
|
||||
}
|
||||
interface WGS84Vector extends L.LatLngLiteral {
|
||||
bearing: number;
|
||||
}
|
||||
interface GeoDistance {
|
||||
distance: number;
|
||||
initialBearing: number;
|
||||
finalBearing: number;
|
||||
}
|
||||
declare class GeodesicCore {
|
||||
readonly options: GeodesicOptions;
|
||||
readonly ellipsoid: {
|
||||
a: number;
|
||||
b: number;
|
||||
f: number;
|
||||
};
|
||||
constructor(options?: GeodesicOptions);
|
||||
toRadians(degree: number): number;
|
||||
toDegrees(radians: number): number;
|
||||
/**
|
||||
* implements scientific modulus
|
||||
* source: http://www.codeavenger.com/2017/05/19/JavaScript-Modulo-operation-and-the-Caesar-Cipher.html
|
||||
* @param n
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
mod(n: number, p: number): number;
|
||||
/**
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/dms.js
|
||||
* @param degrees arbitrary value
|
||||
* @return degrees between 0..360
|
||||
*/
|
||||
wrap360(degrees: number): number;
|
||||
/**
|
||||
* general wrap function with arbitrary max value
|
||||
* @param degrees arbitrary value
|
||||
* @param max
|
||||
* @return degrees between `-max`..`+max`
|
||||
*/
|
||||
wrap(degrees: number, max?: number): number;
|
||||
/**
|
||||
* Vincenty direct calculation.
|
||||
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-ellipsoidal-vincenty.js
|
||||
*
|
||||
* @param start starting point
|
||||
* @param bearing initial bearing (in degrees)
|
||||
* @param distance distance from starting point to calculate along given bearing in meters.
|
||||
* @param maxInterations How many iterations can be made to reach the allowed deviation (`ε`), before an error will be thrown.
|
||||
* @return Final point (destination point) and bearing (in degrees)
|
||||
*/
|
||||
direct(start: L.LatLng, bearing: number, distance: number, maxInterations?: number): WGS84Vector;
|
||||
/**
|
||||
* Vincenty inverse calculation.
|
||||
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-ellipsoidal-vincenty.js
|
||||
*
|
||||
* @param start Latitude/longitude of starting point.
|
||||
* @param dest Latitude/longitude of destination point.
|
||||
* @return Object including distance, initialBearing, finalBearing.
|
||||
*/
|
||||
inverse(start: L.LatLng, dest: L.LatLng, maxInterations?: number, mitigateConvergenceError?: boolean): GeoDistance;
|
||||
/**
|
||||
* Returns the point of intersection of two paths defined by position and bearing.
|
||||
* This calculation uses a spherical model of the earth. This will lead to small errors compared to an ellipsiod model.
|
||||
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-spherical.js
|
||||
*
|
||||
* @param firstPos 1st path: position and bearing
|
||||
* @param firstBearing
|
||||
* @param secondPos 2nd path: position and bearing
|
||||
* @param secondBearing
|
||||
*/
|
||||
intersection(firstPos: L.LatLng, firstBearing: number, secondPos: L.LatLng, secondBearing: number): L.LatLng | null;
|
||||
midpoint(start: L.LatLng, dest: L.LatLng): L.LatLng;
|
||||
}
|
||||
|
||||
/** detailled information of the current geometry */
|
||||
interface Statistics {
|
||||
/** Stores the distance for each individual geodesic line */
|
||||
distanceArray: number[];
|
||||
/** overall distance of all lines */
|
||||
totalDistance: number;
|
||||
/** number of positions that the geodesic lines are created from */
|
||||
points: number;
|
||||
/** number vertices that were created during geometry calculation */
|
||||
vertices: number;
|
||||
}
|
||||
declare class GeodesicGeometry {
|
||||
readonly geodesic: GeodesicCore;
|
||||
steps: number;
|
||||
constructor(options?: GeodesicOptions);
|
||||
/**
|
||||
* A geodesic line between `start` and `dest` is created with this recursive function.
|
||||
* It calculates the geodesic midpoint between `start` and `dest` and uses this midpoint to call itself again (twice!).
|
||||
* The results are then merged into one continuous linestring.
|
||||
*
|
||||
* The number of resulting vertices (incl. `start` and `dest`) depends on the initial value for `iterations`
|
||||
* and can be calculated with: vertices == 1 + 2 ** (initialIterations + 1)
|
||||
*
|
||||
* As this is an exponential function, be extra careful to limit the initial value for `iterations` (8 results in 513 vertices).
|
||||
*
|
||||
* @param start start position
|
||||
* @param dest destination
|
||||
* @param iterations
|
||||
* @return resulting linestring
|
||||
*/
|
||||
recursiveMidpoint(start: L.LatLng, dest: L.LatLng, iterations: number): L.LatLng[];
|
||||
/**
|
||||
* This is the wrapper-function to generate a geodesic line. It's just for future backwards-compatibility
|
||||
* if there is another algorithm used to create the actual line.
|
||||
*
|
||||
* The `steps`-property is used to define the number of resulting vertices of the linestring: vertices == 1 + 2 ** (steps + 1)
|
||||
* The value for `steps` is currently limited to 8 (513 vertices) for performance reasons until another algorithm is found.
|
||||
*
|
||||
* @param start start position
|
||||
* @param dest destination
|
||||
* @return resulting linestring
|
||||
*/
|
||||
line(start: L.LatLng, dest: L.LatLng): L.LatLng[];
|
||||
multiLineString(latlngs: L.LatLng[][]): L.LatLng[][];
|
||||
lineString(latlngs: L.LatLng[]): L.LatLng[];
|
||||
/**
|
||||
*
|
||||
* Is much (10x) faster than the previous implementation:
|
||||
*
|
||||
* ```
|
||||
* Benchmark (no split): splitLine x 459,044 ops/sec ±0.53% (95 runs sampled)
|
||||
* Benchmark (split): splitLine x 42,999 ops/sec ±0.51% (97 runs sampled)
|
||||
* ```
|
||||
*
|
||||
* @param startPosition
|
||||
* @param destPosition
|
||||
*/
|
||||
splitLine(startPosition: L.LatLng, destPosition: L.LatLng): L.LatLng[][];
|
||||
/**
|
||||
* Linestrings of a given multilinestring that cross the antimeridian will be split in two separate linestrings.
|
||||
* This function is used to wrap lines around when they cross the antimeridian
|
||||
* It iterates over all linestrings and reconstructs the step-by-step if no split is needed.
|
||||
* In case the line was split, the linestring ends at the antimeridian and a new linestring is created for the
|
||||
* remaining points of the original linestring.
|
||||
*
|
||||
* @param multilinestring
|
||||
* @return another multilinestring where segments crossing the antimeridian are split
|
||||
*/
|
||||
splitMultiLineString(multilinestring: L.LatLng[][]): L.LatLng[][];
|
||||
/**
|
||||
* Linestrings of a given multilinestring will be wrapped (+- 360°) to show a continuous line w/o any weird discontinuities
|
||||
* when `wrap` is set to `false` in the geodesic class
|
||||
* @param multilinestring
|
||||
* @returns another multilinestring where the points of each linestring are wrapped accordingly
|
||||
*/
|
||||
wrapMultiLineString(multilinestring: L.LatLng[][]): L.LatLng[][];
|
||||
/**
|
||||
* Creates a circular (constant radius), closed (1st pos == last pos) geodesic linestring.
|
||||
* The number of vertices is calculated with: `vertices == steps + 1` (where 1st == last)
|
||||
*
|
||||
* @param center
|
||||
* @param radius
|
||||
* @return resulting linestring
|
||||
*/
|
||||
circle(center: L.LatLng, radius: number): L.LatLng[];
|
||||
/**
|
||||
* Handles splitting of circles at the antimeridian.
|
||||
* @param linestring a linestring that resembles the geodesic circle
|
||||
* @return a multilinestring that consist of one or two linestrings
|
||||
*/
|
||||
splitCircle(linestring: L.LatLng[]): L.LatLng[][];
|
||||
/**
|
||||
* Calculates the distance between two positions on the earths surface
|
||||
* @param start 1st position
|
||||
* @param dest 2nd position
|
||||
* @return the distance in **meters**
|
||||
*/
|
||||
distance(start: L.LatLng, dest: L.LatLng): number;
|
||||
multilineDistance(multilinestring: L.LatLng[][]): number[];
|
||||
updateStatistics(points: L.LatLng[][], vertices: L.LatLng[][]): Statistics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw geodesic lines based on L.Polyline
|
||||
*/
|
||||
declare class GeodesicLine extends L.Polyline {
|
||||
/** these should be good for most use-cases */
|
||||
defaultOptions: GeodesicOptions;
|
||||
/** does the actual geometry calculations */
|
||||
readonly geom: GeodesicGeometry;
|
||||
/** use this if you need some detailled info about the current geometry */
|
||||
statistics: Statistics;
|
||||
/** stores all positions that are used to create the geodesic line */
|
||||
points: L.LatLng[][];
|
||||
constructor(latlngs?: L.LatLngExpression[] | L.LatLngExpression[][], options?: GeodesicOptions);
|
||||
/** calculates the geodesics and update the polyline-object accordingly */
|
||||
private updateGeometry;
|
||||
/**
|
||||
* overwrites the original function with additional functionality to create a geodesic line
|
||||
* @param latlngs an array (or 2d-array) of positions
|
||||
*/
|
||||
setLatLngs(latlngs: L.LatLngExpression[] | L.LatLngExpression[][]): this;
|
||||
/**
|
||||
* add a given point to the geodesic line object
|
||||
* @param latlng point to add. The point will always be added to the last linestring of a multiline
|
||||
* @param latlngs define a linestring to add the new point to. Read from points-property before (e.g. `line.addLatLng(Beijing, line.points[0]);`)
|
||||
*/
|
||||
addLatLng(latlng: L.LatLngExpression, latlngs?: L.LatLng[]): this;
|
||||
/**
|
||||
* Creates geodesic lines from a given GeoJSON-Object.
|
||||
* @param input GeoJSON-Object
|
||||
*/
|
||||
fromGeoJson(input: GeoJSON.GeoJSON): this;
|
||||
/**
|
||||
* Calculates the distance between two geo-positions
|
||||
* @param start 1st position
|
||||
* @param dest 2nd position
|
||||
* @return the distance in meters
|
||||
*/
|
||||
distance(start: L.LatLngExpression, dest: L.LatLngExpression): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to create a geodesic circle based on L.Polyline
|
||||
*/
|
||||
declare class GeodesicCircleClass extends L.Polyline {
|
||||
defaultOptions: GeodesicOptions;
|
||||
readonly geom: GeodesicGeometry;
|
||||
center: L.LatLng;
|
||||
radius: number;
|
||||
statistics: Statistics;
|
||||
constructor(center?: L.LatLngExpression, options?: GeodesicOptions);
|
||||
/**
|
||||
* Updates the geometry and re-calculates some statistics
|
||||
*/
|
||||
private update;
|
||||
/**
|
||||
* Calculate the distance between the current center and an arbitrary position.
|
||||
* @param latlng geo-position to calculate distance to
|
||||
* @return distance in meters
|
||||
*/
|
||||
distanceTo(latlng: L.LatLngExpression): number;
|
||||
/**
|
||||
* Set a new center for the geodesic circle and update the geometry. Radius may also be set.
|
||||
* @param center the new center
|
||||
* @param radius the new radius
|
||||
*/
|
||||
setLatLng(center: L.LatLngExpression, radius?: number): void;
|
||||
/**
|
||||
* Set a new radius for the geodesic circle and update the geometry. Center may also be set.
|
||||
* @param radius the new radius
|
||||
* @param center the new center
|
||||
*/
|
||||
setRadius(radius: number, center?: L.LatLngExpression): void;
|
||||
}
|
||||
|
||||
declare module "leaflet" {
|
||||
type Geodesic = GeodesicLine;
|
||||
let Geodesic: typeof GeodesicLine;
|
||||
let geodesic: (...args: ConstructorParameters<typeof GeodesicLine>) => GeodesicLine;
|
||||
type GeodesicCircle = GeodesicCircleClass;
|
||||
let GeodesicCircle: typeof GeodesicCircleClass;
|
||||
let geodesiccircle: (...args: ConstructorParameters<typeof GeodesicCircleClass>) => GeodesicCircleClass;
|
||||
}
|
||||
|
||||
export { GeodesicCircleClass, GeodesicLine };
|
||||
895
node_modules/leaflet.geodesic/dist/leaflet.geodesic.esm.js
generated
vendored
Normal file
895
node_modules/leaflet.geodesic/dist/leaflet.geodesic.esm.js
generated
vendored
Normal file
|
|
@ -0,0 +1,895 @@
|
|||
/*! leaflet.geodesic 2.7.1 - (c) Henry Thasler - https://github.com/henrythasler/Leaflet.Geodesic#readme */
|
||||
import * as L from 'leaflet';
|
||||
|
||||
/******************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
/* global Reflect, Promise, SuppressedError, Symbol */
|
||||
|
||||
var extendStatics = function(d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
|
||||
function __extends(d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
}
|
||||
|
||||
var __assign = function() {
|
||||
__assign = Object.assign || function __assign(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
|
||||
function __spreadArray(to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
}
|
||||
|
||||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
};
|
||||
|
||||
var GeodesicCore = /** @class */ (function () {
|
||||
function GeodesicCore(options) {
|
||||
this.options = { wrap: true, steps: 3 };
|
||||
this.ellipsoid = {
|
||||
a: 6378137,
|
||||
b: 6356752.3142,
|
||||
f: 1 / 298.257223563
|
||||
}; // WGS-84
|
||||
this.options = __assign(__assign({}, this.options), options);
|
||||
}
|
||||
GeodesicCore.prototype.toRadians = function (degree) {
|
||||
return (degree * Math.PI) / 180;
|
||||
};
|
||||
GeodesicCore.prototype.toDegrees = function (radians) {
|
||||
return (radians * 180) / Math.PI;
|
||||
};
|
||||
/**
|
||||
* implements scientific modulus
|
||||
* source: http://www.codeavenger.com/2017/05/19/JavaScript-Modulo-operation-and-the-Caesar-Cipher.html
|
||||
* @param n
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
GeodesicCore.prototype.mod = function (n, p) {
|
||||
var r = n % p;
|
||||
return r < 0 ? r + p : r;
|
||||
};
|
||||
/**
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/dms.js
|
||||
* @param degrees arbitrary value
|
||||
* @return degrees between 0..360
|
||||
*/
|
||||
GeodesicCore.prototype.wrap360 = function (degrees) {
|
||||
if (0 <= degrees && degrees < 360) {
|
||||
return degrees; // avoid rounding due to arithmetic ops if within range
|
||||
}
|
||||
else {
|
||||
return this.mod(degrees, 360);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* general wrap function with arbitrary max value
|
||||
* @param degrees arbitrary value
|
||||
* @param max
|
||||
* @return degrees between `-max`..`+max`
|
||||
*/
|
||||
GeodesicCore.prototype.wrap = function (degrees, max) {
|
||||
if (max === void 0) { max = 360; }
|
||||
if (-max <= degrees && degrees <= max) {
|
||||
return degrees;
|
||||
}
|
||||
else {
|
||||
return this.mod(degrees + max, 2 * max) - max;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Vincenty direct calculation.
|
||||
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-ellipsoidal-vincenty.js
|
||||
*
|
||||
* @param start starting point
|
||||
* @param bearing initial bearing (in degrees)
|
||||
* @param distance distance from starting point to calculate along given bearing in meters.
|
||||
* @param maxInterations How many iterations can be made to reach the allowed deviation (`ε`), before an error will be thrown.
|
||||
* @return Final point (destination point) and bearing (in degrees)
|
||||
*/
|
||||
GeodesicCore.prototype.direct = function (start, bearing, distance, maxInterations) {
|
||||
if (maxInterations === void 0) { maxInterations = 100; }
|
||||
var φ1 = this.toRadians(start.lat);
|
||||
var λ1 = this.toRadians(start.lng);
|
||||
var α1 = this.toRadians(bearing);
|
||||
var s = distance;
|
||||
var ε = Number.EPSILON * 1000;
|
||||
var _a = this.ellipsoid, a = _a.a, b = _a.b, f = _a.f;
|
||||
var sinα1 = Math.sin(α1);
|
||||
var cosα1 = Math.cos(α1);
|
||||
var tanU1 = (1 - f) * Math.tan(φ1), cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1), sinU1 = tanU1 * cosU1;
|
||||
var σ1 = Math.atan2(tanU1, cosα1); // σ1 = angular distance on the sphere from the equator to P1
|
||||
var sinα = cosU1 * sinα1; // α = azimuth of the geodesic at the equator
|
||||
var cosSqα = 1 - sinα * sinα;
|
||||
var uSq = (cosSqα * (a * a - b * b)) / (b * b);
|
||||
var A = 1 + (uSq / 16384) * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
||||
var B = (uSq / 1024) * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
||||
var σ = s / (b * A), sinσ = null, cosσ = null, Δσ = null; // σ = angular distance P₁ P₂ on the sphere
|
||||
var cos2σₘ = null; // σₘ = angular distance on the sphere from the equator to the midpoint of the line
|
||||
var σʹ = null, iterations = 0;
|
||||
do {
|
||||
cos2σₘ = Math.cos(2 * σ1 + σ);
|
||||
sinσ = Math.sin(σ);
|
||||
cosσ = Math.cos(σ);
|
||||
Δσ =
|
||||
B *
|
||||
sinσ *
|
||||
(cos2σₘ +
|
||||
(B / 4) *
|
||||
(cosσ * (-1 + 2 * cos2σₘ * cos2σₘ) -
|
||||
(B / 6) * cos2σₘ * (-3 + 4 * sinσ * sinσ) * (-3 + 4 * cos2σₘ * cos2σₘ)));
|
||||
σʹ = σ;
|
||||
σ = s / (b * A) + Δσ;
|
||||
} while (Math.abs(σ - σʹ) > ε && ++iterations < maxInterations);
|
||||
if (iterations >= maxInterations) {
|
||||
throw new EvalError("Direct vincenty formula failed to converge after ".concat(maxInterations, " iterations \n (start=").concat(start.lat, "/").concat(start.lng, "; bearing=").concat(bearing, "; distance=").concat(distance, ")")); // not possible?
|
||||
}
|
||||
var x = sinU1 * sinσ - cosU1 * cosσ * cosα1;
|
||||
var φ2 = Math.atan2(sinU1 * cosσ + cosU1 * sinσ * cosα1, (1 - f) * Math.sqrt(sinα * sinα + x * x));
|
||||
var λ = Math.atan2(sinσ * sinα1, cosU1 * cosσ - sinU1 * sinσ * cosα1);
|
||||
var C = (f / 16) * cosSqα * (4 + f * (4 - 3 * cosSqα));
|
||||
var dL = λ - (1 - C) * f * sinα * (σ + C * sinσ * (cos2σₘ + C * cosσ * (-1 + 2 * cos2σₘ * cos2σₘ)));
|
||||
var λ2 = λ1 + dL;
|
||||
var α2 = Math.atan2(sinα, -x);
|
||||
return {
|
||||
lat: this.toDegrees(φ2),
|
||||
lng: this.toDegrees(λ2),
|
||||
bearing: this.wrap360(this.toDegrees(α2))
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Vincenty inverse calculation.
|
||||
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-ellipsoidal-vincenty.js
|
||||
*
|
||||
* @param start Latitude/longitude of starting point.
|
||||
* @param dest Latitude/longitude of destination point.
|
||||
* @return Object including distance, initialBearing, finalBearing.
|
||||
*/
|
||||
GeodesicCore.prototype.inverse = function (start, dest, maxInterations, mitigateConvergenceError) {
|
||||
if (maxInterations === void 0) { maxInterations = 100; }
|
||||
if (mitigateConvergenceError === void 0) { mitigateConvergenceError = true; }
|
||||
var p1 = start, p2 = dest;
|
||||
var φ1 = this.toRadians(p1.lat), λ1 = this.toRadians(p1.lng);
|
||||
var φ2 = this.toRadians(p2.lat), λ2 = this.toRadians(p2.lng);
|
||||
var π = Math.PI;
|
||||
var ε = Number.EPSILON;
|
||||
// allow alternative ellipsoid to be specified
|
||||
var _a = this.ellipsoid, a = _a.a, b = _a.b, f = _a.f;
|
||||
var dL = λ2 - λ1; // L = difference in longitude, U = reduced latitude, defined by tan U = (1-f)·tanφ.
|
||||
var tanU1 = (1 - f) * Math.tan(φ1), cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1), sinU1 = tanU1 * cosU1;
|
||||
var tanU2 = (1 - f) * Math.tan(φ2), cosU2 = 1 / Math.sqrt(1 + tanU2 * tanU2), sinU2 = tanU2 * cosU2;
|
||||
var antipodal = Math.abs(dL) > π / 2 || Math.abs(φ2 - φ1) > π / 2;
|
||||
var λ = dL, sinλ = null, cosλ = null; // λ = difference in longitude on an auxiliary sphere
|
||||
var σ = antipodal ? π : 0, sinσ = 0, cosσ = antipodal ? -1 : 1, sinSqσ = null; // σ = angular distance P₁ P₂ on the sphere
|
||||
var cos2σₘ = 1; // σₘ = angular distance on the sphere from the equator to the midpoint of the line
|
||||
var sinα = null, cosSqα = 1; // α = azimuth of the geodesic at the equator
|
||||
var C = null;
|
||||
var λʹ = null, iterations = 0;
|
||||
do {
|
||||
sinλ = Math.sin(λ);
|
||||
cosλ = Math.cos(λ);
|
||||
sinSqσ =
|
||||
cosU2 * sinλ * (cosU2 * sinλ) +
|
||||
(cosU1 * sinU2 - sinU1 * cosU2 * cosλ) * (cosU1 * sinU2 - sinU1 * cosU2 * cosλ);
|
||||
if (Math.abs(sinSqσ) < ε) {
|
||||
break; // co-incident/antipodal points (falls back on λ/σ = L)
|
||||
}
|
||||
sinσ = Math.sqrt(sinSqσ);
|
||||
cosσ = sinU1 * sinU2 + cosU1 * cosU2 * cosλ;
|
||||
σ = Math.atan2(sinσ, cosσ);
|
||||
sinα = (cosU1 * cosU2 * sinλ) / sinσ;
|
||||
cosSqα = 1 - sinα * sinα;
|
||||
cos2σₘ = cosSqα !== 0 ? cosσ - (2 * sinU1 * sinU2) / cosSqα : 0; // on equatorial line cos²α = 0 (§6)
|
||||
C = (f / 16) * cosSqα * (4 + f * (4 - 3 * cosSqα));
|
||||
λʹ = λ;
|
||||
λ = dL + (1 - C) * f * sinα * (σ + C * sinσ * (cos2σₘ + C * cosσ * (-1 + 2 * cos2σₘ * cos2σₘ)));
|
||||
var iterationCheck = antipodal ? Math.abs(λ) - π : Math.abs(λ);
|
||||
if (iterationCheck > π) {
|
||||
throw new EvalError("λ > π");
|
||||
}
|
||||
} while (Math.abs(λ - λʹ) > 1e-12 && ++iterations < maxInterations);
|
||||
if (iterations >= maxInterations) {
|
||||
if (mitigateConvergenceError) {
|
||||
return this.inverse(start, new L.LatLng(dest.lat, dest.lng - 0.01), maxInterations, mitigateConvergenceError);
|
||||
}
|
||||
else {
|
||||
throw new EvalError("Inverse vincenty formula failed to converge after ".concat(maxInterations, " iterations \n (start=").concat(start.lat, "/").concat(start.lng, "; dest=").concat(dest.lat, "/").concat(dest.lng, ")"));
|
||||
}
|
||||
}
|
||||
var uSq = (cosSqα * (a * a - b * b)) / (b * b);
|
||||
var A = 1 + (uSq / 16384) * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
||||
var B = (uSq / 1024) * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
||||
var Δσ = B *
|
||||
sinσ *
|
||||
(cos2σₘ +
|
||||
(B / 4) *
|
||||
(cosσ * (-1 + 2 * cos2σₘ * cos2σₘ) -
|
||||
(B / 6) * cos2σₘ * (-3 + 4 * sinσ * sinσ) * (-3 + 4 * cos2σₘ * cos2σₘ)));
|
||||
var s = b * A * (σ - Δσ); // s = length of the geodesic
|
||||
// note special handling of exactly antipodal points where sin²σ = 0 (due to discontinuity
|
||||
// atan2(0, 0) = 0 but atan2(this.ε, 0) = π/2 / 90°) - in which case bearing is always meridional,
|
||||
// due north (or due south!)
|
||||
// α = azimuths of the geodesic; α2 the direction P₁ P₂ produced
|
||||
var α1 = Math.abs(sinSqσ) < ε ? 0 : Math.atan2(cosU2 * sinλ, cosU1 * sinU2 - sinU1 * cosU2 * cosλ);
|
||||
var α2 = Math.abs(sinSqσ) < ε ? π : Math.atan2(cosU1 * sinλ, -sinU1 * cosU2 + cosU1 * sinU2 * cosλ);
|
||||
return {
|
||||
distance: s,
|
||||
initialBearing: Math.abs(s) < ε ? NaN : this.wrap360(this.toDegrees(α1)),
|
||||
finalBearing: Math.abs(s) < ε ? NaN : this.wrap360(this.toDegrees(α2))
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Returns the point of intersection of two paths defined by position and bearing.
|
||||
* This calculation uses a spherical model of the earth. This will lead to small errors compared to an ellipsiod model.
|
||||
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-spherical.js
|
||||
*
|
||||
* @param firstPos 1st path: position and bearing
|
||||
* @param firstBearing
|
||||
* @param secondPos 2nd path: position and bearing
|
||||
* @param secondBearing
|
||||
*/
|
||||
GeodesicCore.prototype.intersection = function (firstPos, firstBearing, secondPos, secondBearing) {
|
||||
var φ1 = this.toRadians(firstPos.lat);
|
||||
var λ1 = this.toRadians(firstPos.lng);
|
||||
var φ2 = this.toRadians(secondPos.lat);
|
||||
var λ2 = this.toRadians(secondPos.lng);
|
||||
var θ13 = this.toRadians(firstBearing);
|
||||
var θ23 = this.toRadians(secondBearing);
|
||||
var Δφ = φ2 - φ1, Δλ = λ2 - λ1;
|
||||
var π = Math.PI;
|
||||
var ε = Number.EPSILON;
|
||||
// angular distance p1-p2
|
||||
var δ12 = 2 *
|
||||
Math.asin(Math.sqrt(Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
|
||||
Math.cos(φ1) * Math.cos(φ2) * Math.sin(Δλ / 2) * Math.sin(Δλ / 2)));
|
||||
if (Math.abs(δ12) < ε) {
|
||||
return firstPos; // coincident points
|
||||
}
|
||||
// initial/final bearings between points
|
||||
var cosθa = (Math.sin(φ2) - Math.sin(φ1) * Math.cos(δ12)) / (Math.sin(δ12) * Math.cos(φ1));
|
||||
var cosθb = (Math.sin(φ1) - Math.sin(φ2) * Math.cos(δ12)) / (Math.sin(δ12) * Math.cos(φ2));
|
||||
var θa = Math.acos(Math.min(Math.max(cosθa, -1), 1)); // protect against rounding errors
|
||||
var θb = Math.acos(Math.min(Math.max(cosθb, -1), 1)); // protect against rounding errors
|
||||
var θ12 = Math.sin(λ2 - λ1) > 0 ? θa : 2 * π - θa;
|
||||
var θ21 = Math.sin(λ2 - λ1) > 0 ? 2 * π - θb : θb;
|
||||
var α1 = θ13 - θ12; // angle 2-1-3
|
||||
var α2 = θ21 - θ23; // angle 1-2-3
|
||||
if (Math.sin(α1) === 0 && Math.sin(α2) === 0) {
|
||||
return null; // infinite intersections
|
||||
}
|
||||
if (Math.sin(α1) * Math.sin(α2) < 0) {
|
||||
return null; // ambiguous intersection (antipodal?)
|
||||
}
|
||||
var cosα3 = -Math.cos(α1) * Math.cos(α2) + Math.sin(α1) * Math.sin(α2) * Math.cos(δ12);
|
||||
var δ13 = Math.atan2(Math.sin(δ12) * Math.sin(α1) * Math.sin(α2), Math.cos(α2) + Math.cos(α1) * cosα3);
|
||||
var φ3 = Math.asin(Math.min(Math.max(Math.sin(φ1) * Math.cos(δ13) + Math.cos(φ1) * Math.sin(δ13) * Math.cos(θ13), -1), 1));
|
||||
var Δλ13 = Math.atan2(Math.sin(θ13) * Math.sin(δ13) * Math.cos(φ1), Math.cos(δ13) - Math.sin(φ1) * Math.sin(φ3));
|
||||
var λ3 = λ1 + Δλ13;
|
||||
return new L.LatLng(this.toDegrees(φ3), this.toDegrees(λ3));
|
||||
};
|
||||
GeodesicCore.prototype.midpoint = function (start, dest) {
|
||||
// φm = atan2( sinφ1 + sinφ2, √( (cosφ1 + cosφ2⋅cosΔλ)² + cos²φ2⋅sin²Δλ ) )
|
||||
// λm = λ1 + atan2(cosφ2⋅sinΔλ, cosφ1 + cosφ2⋅cosΔλ)
|
||||
// midpoint is sum of vectors to two points: mathforum.org/library/drmath/view/51822.html
|
||||
var φ1 = this.toRadians(start.lat);
|
||||
var λ1 = this.toRadians(start.lng);
|
||||
var φ2 = this.toRadians(dest.lat);
|
||||
var Δλ = this.toRadians(dest.lng - start.lng);
|
||||
// get cartesian coordinates for the two points
|
||||
var A = { x: Math.cos(φ1), y: 0, z: Math.sin(φ1) }; // place point A on prime meridian y=0
|
||||
var B = { x: Math.cos(φ2) * Math.cos(Δλ), y: Math.cos(φ2) * Math.sin(Δλ), z: Math.sin(φ2) };
|
||||
// vector to midpoint is sum of vectors to two points (no need to normalise)
|
||||
var C = { x: A.x + B.x, y: A.y + B.y, z: A.z + B.z };
|
||||
var φm = Math.atan2(C.z, Math.sqrt(C.x * C.x + C.y * C.y));
|
||||
var λm = λ1 + Math.atan2(C.y, C.x);
|
||||
return new L.LatLng(this.toDegrees(φm), this.toDegrees(λm));
|
||||
};
|
||||
return GeodesicCore;
|
||||
}());
|
||||
|
||||
var GeodesicGeometry = /** @class */ (function () {
|
||||
function GeodesicGeometry(options) {
|
||||
var _a;
|
||||
this.geodesic = new GeodesicCore();
|
||||
this.steps = (_a = options === null || options === void 0 ? void 0 : options.steps) !== null && _a !== void 0 ? _a : 3;
|
||||
}
|
||||
/**
|
||||
* A geodesic line between `start` and `dest` is created with this recursive function.
|
||||
* It calculates the geodesic midpoint between `start` and `dest` and uses this midpoint to call itself again (twice!).
|
||||
* The results are then merged into one continuous linestring.
|
||||
*
|
||||
* The number of resulting vertices (incl. `start` and `dest`) depends on the initial value for `iterations`
|
||||
* and can be calculated with: vertices == 1 + 2 ** (initialIterations + 1)
|
||||
*
|
||||
* As this is an exponential function, be extra careful to limit the initial value for `iterations` (8 results in 513 vertices).
|
||||
*
|
||||
* @param start start position
|
||||
* @param dest destination
|
||||
* @param iterations
|
||||
* @return resulting linestring
|
||||
*/
|
||||
GeodesicGeometry.prototype.recursiveMidpoint = function (start, dest, iterations) {
|
||||
var geom = [start, dest];
|
||||
var midpoint = this.geodesic.midpoint(start, dest);
|
||||
if (iterations > 0) {
|
||||
geom.splice.apply(geom, __spreadArray([0, 1], this.recursiveMidpoint(start, midpoint, iterations - 1), false));
|
||||
geom.splice.apply(geom, __spreadArray([geom.length - 2, 2], this.recursiveMidpoint(midpoint, dest, iterations - 1), false));
|
||||
}
|
||||
else {
|
||||
geom.splice(1, 0, midpoint);
|
||||
}
|
||||
return geom;
|
||||
};
|
||||
/**
|
||||
* This is the wrapper-function to generate a geodesic line. It's just for future backwards-compatibility
|
||||
* if there is another algorithm used to create the actual line.
|
||||
*
|
||||
* The `steps`-property is used to define the number of resulting vertices of the linestring: vertices == 1 + 2 ** (steps + 1)
|
||||
* The value for `steps` is currently limited to 8 (513 vertices) for performance reasons until another algorithm is found.
|
||||
*
|
||||
* @param start start position
|
||||
* @param dest destination
|
||||
* @return resulting linestring
|
||||
*/
|
||||
GeodesicGeometry.prototype.line = function (start, dest) {
|
||||
return this.recursiveMidpoint(start, dest, Math.min(8, this.steps));
|
||||
};
|
||||
GeodesicGeometry.prototype.multiLineString = function (latlngs) {
|
||||
var multiLineString = [];
|
||||
for (var _i = 0, latlngs_1 = latlngs; _i < latlngs_1.length; _i++) {
|
||||
var linestring = latlngs_1[_i];
|
||||
var segment = [];
|
||||
for (var j = 1; j < linestring.length; j++) {
|
||||
segment.splice.apply(segment, __spreadArray([segment.length - 1, 1], this.line(linestring[j - 1], linestring[j]), false));
|
||||
}
|
||||
multiLineString.push(segment);
|
||||
}
|
||||
return multiLineString;
|
||||
};
|
||||
GeodesicGeometry.prototype.lineString = function (latlngs) {
|
||||
return this.multiLineString([latlngs])[0];
|
||||
};
|
||||
/**
|
||||
*
|
||||
* Is much (10x) faster than the previous implementation:
|
||||
*
|
||||
* ```
|
||||
* Benchmark (no split): splitLine x 459,044 ops/sec ±0.53% (95 runs sampled)
|
||||
* Benchmark (split): splitLine x 42,999 ops/sec ±0.51% (97 runs sampled)
|
||||
* ```
|
||||
*
|
||||
* @param startPosition
|
||||
* @param destPosition
|
||||
*/
|
||||
GeodesicGeometry.prototype.splitLine = function (startPosition, destPosition) {
|
||||
var antimeridianWest = {
|
||||
point: new L.LatLng(89.9, -180.0000001),
|
||||
bearing: 180
|
||||
};
|
||||
var antimeridianEast = {
|
||||
point: new L.LatLng(89.9, 180.0000001),
|
||||
bearing: 180
|
||||
};
|
||||
// make a copy to work with
|
||||
var start = new L.LatLng(startPosition.lat, startPosition.lng, startPosition.alt);
|
||||
var dest = new L.LatLng(destPosition.lat, destPosition.lng, destPosition.alt);
|
||||
start.lng = this.geodesic.wrap(start.lng, 360);
|
||||
dest.lng = this.geodesic.wrap(dest.lng, 360);
|
||||
if (dest.lng - start.lng > 180) {
|
||||
dest.lng = dest.lng - 360;
|
||||
}
|
||||
else if (dest.lng - start.lng < -180) {
|
||||
dest.lng = dest.lng + 360;
|
||||
}
|
||||
var result = [
|
||||
[
|
||||
new L.LatLng(start.lat, this.geodesic.wrap(start.lng, 180), start.alt),
|
||||
new L.LatLng(dest.lat, this.geodesic.wrap(dest.lng, 180), dest.alt)
|
||||
]
|
||||
];
|
||||
// crossing antimeridian from "this" side?
|
||||
if (start.lng >= -180 && start.lng <= 180) {
|
||||
// crossing the "western" antimeridian
|
||||
if (dest.lng < -180) {
|
||||
var bearing = this.geodesic.inverse(start, dest).initialBearing;
|
||||
var intersection = this.geodesic.intersection(start, bearing, antimeridianWest.point, antimeridianWest.bearing);
|
||||
if (intersection) {
|
||||
result = [
|
||||
[start, intersection],
|
||||
[
|
||||
new L.LatLng(intersection.lat, intersection.lng + 360),
|
||||
new L.LatLng(dest.lat, dest.lng + 360, dest.alt)
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
// crossing the "eastern" antimeridian
|
||||
else if (dest.lng > 180) {
|
||||
var bearing = this.geodesic.inverse(start, dest).initialBearing;
|
||||
var intersection = this.geodesic.intersection(start, bearing, antimeridianEast.point, antimeridianEast.bearing);
|
||||
if (intersection) {
|
||||
result = [
|
||||
[start, intersection],
|
||||
[
|
||||
new L.LatLng(intersection.lat, intersection.lng - 360),
|
||||
new L.LatLng(dest.lat, dest.lng - 360, dest.alt)
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
// coming back over the antimeridian from the "other" side?
|
||||
else if (dest.lng >= -180 && dest.lng <= 180) {
|
||||
// crossing the "western" antimeridian
|
||||
if (start.lng < -180) {
|
||||
var bearing = this.geodesic.inverse(start, dest).initialBearing;
|
||||
var intersection = this.geodesic.intersection(start, bearing, antimeridianWest.point, antimeridianWest.bearing);
|
||||
if (intersection) {
|
||||
result = [
|
||||
[
|
||||
new L.LatLng(start.lat, start.lng + 360, start.alt),
|
||||
new L.LatLng(intersection.lat, intersection.lng + 360)
|
||||
],
|
||||
[intersection, dest]
|
||||
];
|
||||
}
|
||||
}
|
||||
// crossing the "eastern" antimeridian
|
||||
else if (start.lng > 180) {
|
||||
var bearing = this.geodesic.inverse(start, dest).initialBearing;
|
||||
var intersection = this.geodesic.intersection(start, bearing, antimeridianWest.point, antimeridianWest.bearing);
|
||||
if (intersection) {
|
||||
result = [
|
||||
[
|
||||
new L.LatLng(start.lat, start.lng - 360, start.alt),
|
||||
new L.LatLng(intersection.lat, intersection.lng - 360)
|
||||
],
|
||||
[intersection, dest]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Linestrings of a given multilinestring that cross the antimeridian will be split in two separate linestrings.
|
||||
* This function is used to wrap lines around when they cross the antimeridian
|
||||
* It iterates over all linestrings and reconstructs the step-by-step if no split is needed.
|
||||
* In case the line was split, the linestring ends at the antimeridian and a new linestring is created for the
|
||||
* remaining points of the original linestring.
|
||||
*
|
||||
* @param multilinestring
|
||||
* @return another multilinestring where segments crossing the antimeridian are split
|
||||
*/
|
||||
GeodesicGeometry.prototype.splitMultiLineString = function (multilinestring) {
|
||||
var result = [];
|
||||
for (var _i = 0, multilinestring_1 = multilinestring; _i < multilinestring_1.length; _i++) {
|
||||
var linestring = multilinestring_1[_i];
|
||||
if (linestring.length === 1) {
|
||||
result.push(linestring); // just a single point in linestring, no need to split
|
||||
continue;
|
||||
}
|
||||
var segment = [];
|
||||
for (var j = 1; j < linestring.length; j++) {
|
||||
var split = this.splitLine(linestring[j - 1], linestring[j]);
|
||||
segment.pop();
|
||||
segment = segment.concat(split[0]);
|
||||
if (split.length > 1) {
|
||||
result.push(segment); // the line was split, so we end the linestring right here
|
||||
segment = split[1]; // begin the new linestring with the second part of the split line
|
||||
}
|
||||
}
|
||||
result.push(segment);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Linestrings of a given multilinestring will be wrapped (+- 360°) to show a continuous line w/o any weird discontinuities
|
||||
* when `wrap` is set to `false` in the geodesic class
|
||||
* @param multilinestring
|
||||
* @returns another multilinestring where the points of each linestring are wrapped accordingly
|
||||
*/
|
||||
GeodesicGeometry.prototype.wrapMultiLineString = function (multilinestring) {
|
||||
var result = [];
|
||||
for (var _i = 0, multilinestring_2 = multilinestring; _i < multilinestring_2.length; _i++) {
|
||||
var linestring = multilinestring_2[_i];
|
||||
var resultLine = [];
|
||||
var previous = null;
|
||||
// iterate over every point and check if it needs to be wrapped
|
||||
for (var _a = 0, linestring_1 = linestring; _a < linestring_1.length; _a++) {
|
||||
var point = linestring_1[_a];
|
||||
if (previous === null) {
|
||||
// the first point is the anchor of the linestring from which the line will always start (w/o any wrapping applied)
|
||||
resultLine.push(new L.LatLng(point.lat, point.lng));
|
||||
previous = new L.LatLng(point.lat, point.lng);
|
||||
}
|
||||
else {
|
||||
// I prefer clearly defined branches over a continue-operation.
|
||||
// if the difference between the current and *previous* point is greater than 360°, the current point needs to be shifted
|
||||
// to be on the same 'sphere' as the previous one.
|
||||
var offset = Math.round((point.lng - previous.lng) / 360);
|
||||
// shift the point accordingly and add to the result
|
||||
resultLine.push(new L.LatLng(point.lat, point.lng - offset * 360));
|
||||
// use the wrapped point as the anchor for the next one
|
||||
previous = new L.LatLng(point.lat, point.lng - offset * 360); // Need a new object here, to avoid changing the input data
|
||||
}
|
||||
}
|
||||
result.push(resultLine);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Creates a circular (constant radius), closed (1st pos == last pos) geodesic linestring.
|
||||
* The number of vertices is calculated with: `vertices == steps + 1` (where 1st == last)
|
||||
*
|
||||
* @param center
|
||||
* @param radius
|
||||
* @return resulting linestring
|
||||
*/
|
||||
GeodesicGeometry.prototype.circle = function (center, radius) {
|
||||
var vertices = [];
|
||||
for (var i = 0; i < this.steps; i++) {
|
||||
var point = this.geodesic.direct(center, (360 / this.steps) * i, radius);
|
||||
vertices.push(new L.LatLng(point.lat, point.lng));
|
||||
}
|
||||
// append first vertice to the end to close the linestring
|
||||
vertices.push(new L.LatLng(vertices[0].lat, vertices[0].lng));
|
||||
return vertices;
|
||||
};
|
||||
/**
|
||||
* Handles splitting of circles at the antimeridian.
|
||||
* @param linestring a linestring that resembles the geodesic circle
|
||||
* @return a multilinestring that consist of one or two linestrings
|
||||
*/
|
||||
GeodesicGeometry.prototype.splitCircle = function (linestring) {
|
||||
var result = this.splitMultiLineString([linestring]);
|
||||
// If the circle was split, it results in exactly three linestrings where first and last
|
||||
// must be re-assembled because they belong to the same "side" of the split circle.
|
||||
if (result.length === 3) {
|
||||
result[2] = __spreadArray(__spreadArray([], result[2], true), result[0], true);
|
||||
result.shift();
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Calculates the distance between two positions on the earths surface
|
||||
* @param start 1st position
|
||||
* @param dest 2nd position
|
||||
* @return the distance in **meters**
|
||||
*/
|
||||
GeodesicGeometry.prototype.distance = function (start, dest) {
|
||||
return this.geodesic.inverse(new L.LatLng(start.lat, this.geodesic.wrap(start.lng, 180)), new L.LatLng(dest.lat, this.geodesic.wrap(dest.lng, 180))).distance;
|
||||
};
|
||||
GeodesicGeometry.prototype.multilineDistance = function (multilinestring) {
|
||||
var dist = [];
|
||||
for (var _i = 0, multilinestring_3 = multilinestring; _i < multilinestring_3.length; _i++) {
|
||||
var linestring = multilinestring_3[_i];
|
||||
var segmentDistance = 0;
|
||||
for (var j = 1; j < linestring.length; j++) {
|
||||
segmentDistance += this.distance(linestring[j - 1], linestring[j]);
|
||||
}
|
||||
dist.push(segmentDistance);
|
||||
}
|
||||
return dist;
|
||||
};
|
||||
GeodesicGeometry.prototype.updateStatistics = function (points, vertices) {
|
||||
var stats = { distanceArray: [], totalDistance: 0, points: 0, vertices: 0 };
|
||||
stats.distanceArray = this.multilineDistance(points);
|
||||
stats.totalDistance = stats.distanceArray.reduce(function (x, y) { return x + y; }, 0);
|
||||
stats.points = 0;
|
||||
for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
|
||||
var item = points_1[_i];
|
||||
stats.points += item.reduce(function (x) { return x + 1; }, 0);
|
||||
}
|
||||
stats.vertices = 0;
|
||||
for (var _a = 0, vertices_1 = vertices; _a < vertices_1.length; _a++) {
|
||||
var item = vertices_1[_a];
|
||||
stats.vertices += item.reduce(function (x) { return x + 1; }, 0);
|
||||
}
|
||||
return stats;
|
||||
};
|
||||
return GeodesicGeometry;
|
||||
}());
|
||||
|
||||
function instanceOfLatLngLiteral(object) {
|
||||
return ((typeof object === "object")
|
||||
&& (object !== null)
|
||||
&& ("lat" in object)
|
||||
&& ("lng" in object)
|
||||
&& (typeof object.lat === "number")
|
||||
&& (typeof object.lng === "number"));
|
||||
}
|
||||
function instanceOfLatLngTuple(object) {
|
||||
return ((object instanceof Array)
|
||||
&& (typeof object[0] === "number")
|
||||
&& (typeof object[1] === "number"));
|
||||
}
|
||||
function instanceOfLatLngExpression(object) {
|
||||
return object instanceof L.LatLng || instanceOfLatLngTuple(object) || instanceOfLatLngLiteral(object);
|
||||
}
|
||||
function latlngExpressiontoLatLng(input) {
|
||||
if (input instanceof L.LatLng) {
|
||||
return input;
|
||||
}
|
||||
else if (instanceOfLatLngTuple(input)) {
|
||||
return new L.LatLng(input[0], input[1], input.at(2)); // alt is optional
|
||||
}
|
||||
else if (instanceOfLatLngLiteral(input)) {
|
||||
return new L.LatLng(input.lat, input.lng, input.alt);
|
||||
}
|
||||
throw new Error("L.LatLngExpression expected. Unknown object found.");
|
||||
}
|
||||
function latlngExpressionArraytoLatLngArray(input) {
|
||||
var latlng = [];
|
||||
var iterateOver = instanceOfLatLngExpression(input[0]) ? [input] : input;
|
||||
var unknownObjectError = new Error("L.LatLngExpression[] | L.LatLngExpression[][] expected. Unknown object found.");
|
||||
if (!(iterateOver instanceof Array)) {
|
||||
throw unknownObjectError;
|
||||
}
|
||||
for (var _i = 0, _a = iterateOver; _i < _a.length; _i++) {
|
||||
var group = _a[_i];
|
||||
if (!(group instanceof Array)) {
|
||||
throw unknownObjectError;
|
||||
}
|
||||
var sub = [];
|
||||
for (var _b = 0, group_1 = group; _b < group_1.length; _b++) {
|
||||
var point = group_1[_b];
|
||||
if (!instanceOfLatLngExpression(point)) {
|
||||
throw unknownObjectError;
|
||||
}
|
||||
sub.push(latlngExpressiontoLatLng(point));
|
||||
}
|
||||
latlng.push(sub);
|
||||
}
|
||||
return latlng;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw geodesic lines based on L.Polyline
|
||||
*/
|
||||
var GeodesicLine = /** @class */ (function (_super) {
|
||||
__extends(GeodesicLine, _super);
|
||||
function GeodesicLine(latlngs, options) {
|
||||
var _this = _super.call(this, [], options) || this;
|
||||
/** these should be good for most use-cases */
|
||||
_this.defaultOptions = { wrap: true, steps: 3 };
|
||||
/** use this if you need some detailled info about the current geometry */
|
||||
_this.statistics = { distanceArray: [], totalDistance: 0, points: 0, vertices: 0 };
|
||||
/** stores all positions that are used to create the geodesic line */
|
||||
_this.points = [];
|
||||
L.Util.setOptions(_this, __assign(__assign({}, _this.defaultOptions), options));
|
||||
_this.geom = new GeodesicGeometry(_this.options);
|
||||
if (latlngs !== undefined) {
|
||||
_this.setLatLngs(latlngs);
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
/** calculates the geodesics and update the polyline-object accordingly */
|
||||
GeodesicLine.prototype.updateGeometry = function () {
|
||||
var geodesic = [];
|
||||
geodesic = this.geom.multiLineString(this.points);
|
||||
this.statistics = this.geom.updateStatistics(this.points, geodesic);
|
||||
if (this.options.wrap) {
|
||||
var split = this.geom.splitMultiLineString(geodesic);
|
||||
_super.prototype.setLatLngs.call(this, split);
|
||||
}
|
||||
else {
|
||||
_super.prototype.setLatLngs.call(this, this.geom.wrapMultiLineString(geodesic));
|
||||
}
|
||||
};
|
||||
/**
|
||||
* overwrites the original function with additional functionality to create a geodesic line
|
||||
* @param latlngs an array (or 2d-array) of positions
|
||||
*/
|
||||
GeodesicLine.prototype.setLatLngs = function (latlngs) {
|
||||
this.points = latlngExpressionArraytoLatLngArray(latlngs);
|
||||
this.updateGeometry();
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* add a given point to the geodesic line object
|
||||
* @param latlng point to add. The point will always be added to the last linestring of a multiline
|
||||
* @param latlngs define a linestring to add the new point to. Read from points-property before (e.g. `line.addLatLng(Beijing, line.points[0]);`)
|
||||
*/
|
||||
GeodesicLine.prototype.addLatLng = function (latlng, latlngs) {
|
||||
var point = latlngExpressiontoLatLng(latlng);
|
||||
if (this.points.length === 0) {
|
||||
this.points.push([point]);
|
||||
}
|
||||
else if (latlngs === undefined) {
|
||||
this.points[this.points.length - 1].push(point);
|
||||
}
|
||||
else {
|
||||
latlngs.push(point);
|
||||
}
|
||||
this.updateGeometry();
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* Creates geodesic lines from a given GeoJSON-Object.
|
||||
* @param input GeoJSON-Object
|
||||
*/
|
||||
GeodesicLine.prototype.fromGeoJson = function (input) {
|
||||
var latlngs = [];
|
||||
var features = [];
|
||||
if (input.type === "FeatureCollection") {
|
||||
features = input.features;
|
||||
}
|
||||
else if (input.type === "Feature") {
|
||||
features = [input];
|
||||
}
|
||||
else if (["MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"].includes(input.type)) {
|
||||
features = [
|
||||
{
|
||||
type: "Feature",
|
||||
geometry: input,
|
||||
properties: {}
|
||||
}
|
||||
];
|
||||
}
|
||||
else {
|
||||
console.log("[Leaflet.Geodesic] fromGeoJson() - Type \"".concat(input.type, "\" not supported."));
|
||||
}
|
||||
features.forEach(function (feature) {
|
||||
switch (feature.geometry.type) {
|
||||
case "MultiPoint":
|
||||
case "LineString":
|
||||
latlngs = __spreadArray(__spreadArray([], latlngs, true), [L.GeoJSON.coordsToLatLngs(feature.geometry.coordinates, 0)], false);
|
||||
break;
|
||||
case "MultiLineString":
|
||||
case "Polygon":
|
||||
latlngs = __spreadArray(__spreadArray([], latlngs, true), L.GeoJSON.coordsToLatLngs(feature.geometry.coordinates, 1), true);
|
||||
break;
|
||||
case "MultiPolygon":
|
||||
feature.geometry.coordinates.forEach(function (item) {
|
||||
latlngs = __spreadArray(__spreadArray([], latlngs, true), L.GeoJSON.coordsToLatLngs(item, 1), true);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
console.log("[Leaflet.Geodesic] fromGeoJson() - Type \"".concat(feature.geometry.type, "\" not supported."));
|
||||
}
|
||||
});
|
||||
if (latlngs.length) {
|
||||
this.setLatLngs(latlngs);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* Calculates the distance between two geo-positions
|
||||
* @param start 1st position
|
||||
* @param dest 2nd position
|
||||
* @return the distance in meters
|
||||
*/
|
||||
GeodesicLine.prototype.distance = function (start, dest) {
|
||||
return this.geom.distance(latlngExpressiontoLatLng(start), latlngExpressiontoLatLng(dest));
|
||||
};
|
||||
return GeodesicLine;
|
||||
}(L.Polyline));
|
||||
|
||||
/**
|
||||
* Can be used to create a geodesic circle based on L.Polyline
|
||||
*/
|
||||
var GeodesicCircleClass = /** @class */ (function (_super) {
|
||||
__extends(GeodesicCircleClass, _super);
|
||||
function GeodesicCircleClass(center, options) {
|
||||
var _a;
|
||||
var _this = _super.call(this, [], options) || this;
|
||||
_this.defaultOptions = { wrap: true, steps: 24, fill: true, noClip: true };
|
||||
_this.statistics = { distanceArray: [], totalDistance: 0, points: 0, vertices: 0 };
|
||||
L.Util.setOptions(_this, __assign(__assign({}, _this.defaultOptions), options));
|
||||
// merge/set options
|
||||
var extendedOptions = _this.options;
|
||||
_this.radius = (_a = extendedOptions.radius) !== null && _a !== void 0 ? _a : 1000 * 1000;
|
||||
_this.center = center === undefined ? new L.LatLng(0, 0) : latlngExpressiontoLatLng(center);
|
||||
_this.geom = new GeodesicGeometry(_this.options);
|
||||
// update the geometry
|
||||
_this.update();
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Updates the geometry and re-calculates some statistics
|
||||
*/
|
||||
GeodesicCircleClass.prototype.update = function () {
|
||||
var circle = this.geom.circle(this.center, this.radius);
|
||||
this.statistics = this.geom.updateStatistics([[this.center]], [circle]);
|
||||
// circumfence must be re-calculated from geodesic
|
||||
this.statistics.totalDistance = this.geom.multilineDistance([circle]).reduce(function (x, y) { return x + y; }, 0);
|
||||
if (this.options.wrap) {
|
||||
var split = this.geom.splitCircle(circle);
|
||||
_super.prototype.setLatLngs.call(this, split);
|
||||
}
|
||||
else {
|
||||
_super.prototype.setLatLngs.call(this, circle);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Calculate the distance between the current center and an arbitrary position.
|
||||
* @param latlng geo-position to calculate distance to
|
||||
* @return distance in meters
|
||||
*/
|
||||
GeodesicCircleClass.prototype.distanceTo = function (latlng) {
|
||||
var dest = latlngExpressiontoLatLng(latlng);
|
||||
return this.geom.distance(this.center, dest);
|
||||
};
|
||||
/**
|
||||
* Set a new center for the geodesic circle and update the geometry. Radius may also be set.
|
||||
* @param center the new center
|
||||
* @param radius the new radius
|
||||
*/
|
||||
GeodesicCircleClass.prototype.setLatLng = function (center, radius) {
|
||||
this.center = latlngExpressiontoLatLng(center);
|
||||
this.radius = radius !== null && radius !== void 0 ? radius : this.radius;
|
||||
this.update();
|
||||
};
|
||||
/**
|
||||
* Set a new radius for the geodesic circle and update the geometry. Center may also be set.
|
||||
* @param radius the new radius
|
||||
* @param center the new center
|
||||
*/
|
||||
GeodesicCircleClass.prototype.setRadius = function (radius, center) {
|
||||
this.radius = radius;
|
||||
this.center = center ? latlngExpressiontoLatLng(center) : this.center;
|
||||
this.update();
|
||||
};
|
||||
return GeodesicCircleClass;
|
||||
}(L.Polyline));
|
||||
|
||||
if (typeof window.L !== "undefined") {
|
||||
window.L.Geodesic = GeodesicLine;
|
||||
window.L.geodesic = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return new (GeodesicLine.bind.apply(GeodesicLine, __spreadArray([void 0], args, false)))();
|
||||
};
|
||||
window.L.GeodesicCircle = GeodesicCircleClass;
|
||||
window.L.geodesiccircle = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return new (GeodesicCircleClass.bind.apply(GeodesicCircleClass, __spreadArray([void 0], args, false)))();
|
||||
};
|
||||
}
|
||||
|
||||
export { GeodesicCircleClass, GeodesicLine };
|
||||
917
node_modules/leaflet.geodesic/dist/leaflet.geodesic.js
generated
vendored
Normal file
917
node_modules/leaflet.geodesic/dist/leaflet.geodesic.js
generated
vendored
Normal file
|
|
@ -0,0 +1,917 @@
|
|||
/*! leaflet.geodesic 2.7.1 - (c) Henry Thasler - https://github.com/henrythasler/Leaflet.Geodesic#readme */
|
||||
'use strict';
|
||||
|
||||
var L = require('leaflet');
|
||||
|
||||
function _interopNamespaceDefault(e) {
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n.default = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var L__namespace = /*#__PURE__*/_interopNamespaceDefault(L);
|
||||
|
||||
/******************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
/* global Reflect, Promise, SuppressedError, Symbol */
|
||||
|
||||
var extendStatics = function(d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
|
||||
function __extends(d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
}
|
||||
|
||||
var __assign = function() {
|
||||
__assign = Object.assign || function __assign(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
|
||||
function __spreadArray(to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
}
|
||||
|
||||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
};
|
||||
|
||||
var GeodesicCore = /** @class */ (function () {
|
||||
function GeodesicCore(options) {
|
||||
this.options = { wrap: true, steps: 3 };
|
||||
this.ellipsoid = {
|
||||
a: 6378137,
|
||||
b: 6356752.3142,
|
||||
f: 1 / 298.257223563
|
||||
}; // WGS-84
|
||||
this.options = __assign(__assign({}, this.options), options);
|
||||
}
|
||||
GeodesicCore.prototype.toRadians = function (degree) {
|
||||
return (degree * Math.PI) / 180;
|
||||
};
|
||||
GeodesicCore.prototype.toDegrees = function (radians) {
|
||||
return (radians * 180) / Math.PI;
|
||||
};
|
||||
/**
|
||||
* implements scientific modulus
|
||||
* source: http://www.codeavenger.com/2017/05/19/JavaScript-Modulo-operation-and-the-Caesar-Cipher.html
|
||||
* @param n
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
GeodesicCore.prototype.mod = function (n, p) {
|
||||
var r = n % p;
|
||||
return r < 0 ? r + p : r;
|
||||
};
|
||||
/**
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/dms.js
|
||||
* @param degrees arbitrary value
|
||||
* @return degrees between 0..360
|
||||
*/
|
||||
GeodesicCore.prototype.wrap360 = function (degrees) {
|
||||
if (0 <= degrees && degrees < 360) {
|
||||
return degrees; // avoid rounding due to arithmetic ops if within range
|
||||
}
|
||||
else {
|
||||
return this.mod(degrees, 360);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* general wrap function with arbitrary max value
|
||||
* @param degrees arbitrary value
|
||||
* @param max
|
||||
* @return degrees between `-max`..`+max`
|
||||
*/
|
||||
GeodesicCore.prototype.wrap = function (degrees, max) {
|
||||
if (max === void 0) { max = 360; }
|
||||
if (-max <= degrees && degrees <= max) {
|
||||
return degrees;
|
||||
}
|
||||
else {
|
||||
return this.mod(degrees + max, 2 * max) - max;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Vincenty direct calculation.
|
||||
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-ellipsoidal-vincenty.js
|
||||
*
|
||||
* @param start starting point
|
||||
* @param bearing initial bearing (in degrees)
|
||||
* @param distance distance from starting point to calculate along given bearing in meters.
|
||||
* @param maxInterations How many iterations can be made to reach the allowed deviation (`ε`), before an error will be thrown.
|
||||
* @return Final point (destination point) and bearing (in degrees)
|
||||
*/
|
||||
GeodesicCore.prototype.direct = function (start, bearing, distance, maxInterations) {
|
||||
if (maxInterations === void 0) { maxInterations = 100; }
|
||||
var φ1 = this.toRadians(start.lat);
|
||||
var λ1 = this.toRadians(start.lng);
|
||||
var α1 = this.toRadians(bearing);
|
||||
var s = distance;
|
||||
var ε = Number.EPSILON * 1000;
|
||||
var _a = this.ellipsoid, a = _a.a, b = _a.b, f = _a.f;
|
||||
var sinα1 = Math.sin(α1);
|
||||
var cosα1 = Math.cos(α1);
|
||||
var tanU1 = (1 - f) * Math.tan(φ1), cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1), sinU1 = tanU1 * cosU1;
|
||||
var σ1 = Math.atan2(tanU1, cosα1); // σ1 = angular distance on the sphere from the equator to P1
|
||||
var sinα = cosU1 * sinα1; // α = azimuth of the geodesic at the equator
|
||||
var cosSqα = 1 - sinα * sinα;
|
||||
var uSq = (cosSqα * (a * a - b * b)) / (b * b);
|
||||
var A = 1 + (uSq / 16384) * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
||||
var B = (uSq / 1024) * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
||||
var σ = s / (b * A), sinσ = null, cosσ = null, Δσ = null; // σ = angular distance P₁ P₂ on the sphere
|
||||
var cos2σₘ = null; // σₘ = angular distance on the sphere from the equator to the midpoint of the line
|
||||
var σʹ = null, iterations = 0;
|
||||
do {
|
||||
cos2σₘ = Math.cos(2 * σ1 + σ);
|
||||
sinσ = Math.sin(σ);
|
||||
cosσ = Math.cos(σ);
|
||||
Δσ =
|
||||
B *
|
||||
sinσ *
|
||||
(cos2σₘ +
|
||||
(B / 4) *
|
||||
(cosσ * (-1 + 2 * cos2σₘ * cos2σₘ) -
|
||||
(B / 6) * cos2σₘ * (-3 + 4 * sinσ * sinσ) * (-3 + 4 * cos2σₘ * cos2σₘ)));
|
||||
σʹ = σ;
|
||||
σ = s / (b * A) + Δσ;
|
||||
} while (Math.abs(σ - σʹ) > ε && ++iterations < maxInterations);
|
||||
if (iterations >= maxInterations) {
|
||||
throw new EvalError("Direct vincenty formula failed to converge after ".concat(maxInterations, " iterations \n (start=").concat(start.lat, "/").concat(start.lng, "; bearing=").concat(bearing, "; distance=").concat(distance, ")")); // not possible?
|
||||
}
|
||||
var x = sinU1 * sinσ - cosU1 * cosσ * cosα1;
|
||||
var φ2 = Math.atan2(sinU1 * cosσ + cosU1 * sinσ * cosα1, (1 - f) * Math.sqrt(sinα * sinα + x * x));
|
||||
var λ = Math.atan2(sinσ * sinα1, cosU1 * cosσ - sinU1 * sinσ * cosα1);
|
||||
var C = (f / 16) * cosSqα * (4 + f * (4 - 3 * cosSqα));
|
||||
var dL = λ - (1 - C) * f * sinα * (σ + C * sinσ * (cos2σₘ + C * cosσ * (-1 + 2 * cos2σₘ * cos2σₘ)));
|
||||
var λ2 = λ1 + dL;
|
||||
var α2 = Math.atan2(sinα, -x);
|
||||
return {
|
||||
lat: this.toDegrees(φ2),
|
||||
lng: this.toDegrees(λ2),
|
||||
bearing: this.wrap360(this.toDegrees(α2))
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Vincenty inverse calculation.
|
||||
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-ellipsoidal-vincenty.js
|
||||
*
|
||||
* @param start Latitude/longitude of starting point.
|
||||
* @param dest Latitude/longitude of destination point.
|
||||
* @return Object including distance, initialBearing, finalBearing.
|
||||
*/
|
||||
GeodesicCore.prototype.inverse = function (start, dest, maxInterations, mitigateConvergenceError) {
|
||||
if (maxInterations === void 0) { maxInterations = 100; }
|
||||
if (mitigateConvergenceError === void 0) { mitigateConvergenceError = true; }
|
||||
var p1 = start, p2 = dest;
|
||||
var φ1 = this.toRadians(p1.lat), λ1 = this.toRadians(p1.lng);
|
||||
var φ2 = this.toRadians(p2.lat), λ2 = this.toRadians(p2.lng);
|
||||
var π = Math.PI;
|
||||
var ε = Number.EPSILON;
|
||||
// allow alternative ellipsoid to be specified
|
||||
var _a = this.ellipsoid, a = _a.a, b = _a.b, f = _a.f;
|
||||
var dL = λ2 - λ1; // L = difference in longitude, U = reduced latitude, defined by tan U = (1-f)·tanφ.
|
||||
var tanU1 = (1 - f) * Math.tan(φ1), cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1), sinU1 = tanU1 * cosU1;
|
||||
var tanU2 = (1 - f) * Math.tan(φ2), cosU2 = 1 / Math.sqrt(1 + tanU2 * tanU2), sinU2 = tanU2 * cosU2;
|
||||
var antipodal = Math.abs(dL) > π / 2 || Math.abs(φ2 - φ1) > π / 2;
|
||||
var λ = dL, sinλ = null, cosλ = null; // λ = difference in longitude on an auxiliary sphere
|
||||
var σ = antipodal ? π : 0, sinσ = 0, cosσ = antipodal ? -1 : 1, sinSqσ = null; // σ = angular distance P₁ P₂ on the sphere
|
||||
var cos2σₘ = 1; // σₘ = angular distance on the sphere from the equator to the midpoint of the line
|
||||
var sinα = null, cosSqα = 1; // α = azimuth of the geodesic at the equator
|
||||
var C = null;
|
||||
var λʹ = null, iterations = 0;
|
||||
do {
|
||||
sinλ = Math.sin(λ);
|
||||
cosλ = Math.cos(λ);
|
||||
sinSqσ =
|
||||
cosU2 * sinλ * (cosU2 * sinλ) +
|
||||
(cosU1 * sinU2 - sinU1 * cosU2 * cosλ) * (cosU1 * sinU2 - sinU1 * cosU2 * cosλ);
|
||||
if (Math.abs(sinSqσ) < ε) {
|
||||
break; // co-incident/antipodal points (falls back on λ/σ = L)
|
||||
}
|
||||
sinσ = Math.sqrt(sinSqσ);
|
||||
cosσ = sinU1 * sinU2 + cosU1 * cosU2 * cosλ;
|
||||
σ = Math.atan2(sinσ, cosσ);
|
||||
sinα = (cosU1 * cosU2 * sinλ) / sinσ;
|
||||
cosSqα = 1 - sinα * sinα;
|
||||
cos2σₘ = cosSqα !== 0 ? cosσ - (2 * sinU1 * sinU2) / cosSqα : 0; // on equatorial line cos²α = 0 (§6)
|
||||
C = (f / 16) * cosSqα * (4 + f * (4 - 3 * cosSqα));
|
||||
λʹ = λ;
|
||||
λ = dL + (1 - C) * f * sinα * (σ + C * sinσ * (cos2σₘ + C * cosσ * (-1 + 2 * cos2σₘ * cos2σₘ)));
|
||||
var iterationCheck = antipodal ? Math.abs(λ) - π : Math.abs(λ);
|
||||
if (iterationCheck > π) {
|
||||
throw new EvalError("λ > π");
|
||||
}
|
||||
} while (Math.abs(λ - λʹ) > 1e-12 && ++iterations < maxInterations);
|
||||
if (iterations >= maxInterations) {
|
||||
if (mitigateConvergenceError) {
|
||||
return this.inverse(start, new L__namespace.LatLng(dest.lat, dest.lng - 0.01), maxInterations, mitigateConvergenceError);
|
||||
}
|
||||
else {
|
||||
throw new EvalError("Inverse vincenty formula failed to converge after ".concat(maxInterations, " iterations \n (start=").concat(start.lat, "/").concat(start.lng, "; dest=").concat(dest.lat, "/").concat(dest.lng, ")"));
|
||||
}
|
||||
}
|
||||
var uSq = (cosSqα * (a * a - b * b)) / (b * b);
|
||||
var A = 1 + (uSq / 16384) * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
||||
var B = (uSq / 1024) * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
||||
var Δσ = B *
|
||||
sinσ *
|
||||
(cos2σₘ +
|
||||
(B / 4) *
|
||||
(cosσ * (-1 + 2 * cos2σₘ * cos2σₘ) -
|
||||
(B / 6) * cos2σₘ * (-3 + 4 * sinσ * sinσ) * (-3 + 4 * cos2σₘ * cos2σₘ)));
|
||||
var s = b * A * (σ - Δσ); // s = length of the geodesic
|
||||
// note special handling of exactly antipodal points where sin²σ = 0 (due to discontinuity
|
||||
// atan2(0, 0) = 0 but atan2(this.ε, 0) = π/2 / 90°) - in which case bearing is always meridional,
|
||||
// due north (or due south!)
|
||||
// α = azimuths of the geodesic; α2 the direction P₁ P₂ produced
|
||||
var α1 = Math.abs(sinSqσ) < ε ? 0 : Math.atan2(cosU2 * sinλ, cosU1 * sinU2 - sinU1 * cosU2 * cosλ);
|
||||
var α2 = Math.abs(sinSqσ) < ε ? π : Math.atan2(cosU1 * sinλ, -sinU1 * cosU2 + cosU1 * sinU2 * cosλ);
|
||||
return {
|
||||
distance: s,
|
||||
initialBearing: Math.abs(s) < ε ? NaN : this.wrap360(this.toDegrees(α1)),
|
||||
finalBearing: Math.abs(s) < ε ? NaN : this.wrap360(this.toDegrees(α2))
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Returns the point of intersection of two paths defined by position and bearing.
|
||||
* This calculation uses a spherical model of the earth. This will lead to small errors compared to an ellipsiod model.
|
||||
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-spherical.js
|
||||
*
|
||||
* @param firstPos 1st path: position and bearing
|
||||
* @param firstBearing
|
||||
* @param secondPos 2nd path: position and bearing
|
||||
* @param secondBearing
|
||||
*/
|
||||
GeodesicCore.prototype.intersection = function (firstPos, firstBearing, secondPos, secondBearing) {
|
||||
var φ1 = this.toRadians(firstPos.lat);
|
||||
var λ1 = this.toRadians(firstPos.lng);
|
||||
var φ2 = this.toRadians(secondPos.lat);
|
||||
var λ2 = this.toRadians(secondPos.lng);
|
||||
var θ13 = this.toRadians(firstBearing);
|
||||
var θ23 = this.toRadians(secondBearing);
|
||||
var Δφ = φ2 - φ1, Δλ = λ2 - λ1;
|
||||
var π = Math.PI;
|
||||
var ε = Number.EPSILON;
|
||||
// angular distance p1-p2
|
||||
var δ12 = 2 *
|
||||
Math.asin(Math.sqrt(Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
|
||||
Math.cos(φ1) * Math.cos(φ2) * Math.sin(Δλ / 2) * Math.sin(Δλ / 2)));
|
||||
if (Math.abs(δ12) < ε) {
|
||||
return firstPos; // coincident points
|
||||
}
|
||||
// initial/final bearings between points
|
||||
var cosθa = (Math.sin(φ2) - Math.sin(φ1) * Math.cos(δ12)) / (Math.sin(δ12) * Math.cos(φ1));
|
||||
var cosθb = (Math.sin(φ1) - Math.sin(φ2) * Math.cos(δ12)) / (Math.sin(δ12) * Math.cos(φ2));
|
||||
var θa = Math.acos(Math.min(Math.max(cosθa, -1), 1)); // protect against rounding errors
|
||||
var θb = Math.acos(Math.min(Math.max(cosθb, -1), 1)); // protect against rounding errors
|
||||
var θ12 = Math.sin(λ2 - λ1) > 0 ? θa : 2 * π - θa;
|
||||
var θ21 = Math.sin(λ2 - λ1) > 0 ? 2 * π - θb : θb;
|
||||
var α1 = θ13 - θ12; // angle 2-1-3
|
||||
var α2 = θ21 - θ23; // angle 1-2-3
|
||||
if (Math.sin(α1) === 0 && Math.sin(α2) === 0) {
|
||||
return null; // infinite intersections
|
||||
}
|
||||
if (Math.sin(α1) * Math.sin(α2) < 0) {
|
||||
return null; // ambiguous intersection (antipodal?)
|
||||
}
|
||||
var cosα3 = -Math.cos(α1) * Math.cos(α2) + Math.sin(α1) * Math.sin(α2) * Math.cos(δ12);
|
||||
var δ13 = Math.atan2(Math.sin(δ12) * Math.sin(α1) * Math.sin(α2), Math.cos(α2) + Math.cos(α1) * cosα3);
|
||||
var φ3 = Math.asin(Math.min(Math.max(Math.sin(φ1) * Math.cos(δ13) + Math.cos(φ1) * Math.sin(δ13) * Math.cos(θ13), -1), 1));
|
||||
var Δλ13 = Math.atan2(Math.sin(θ13) * Math.sin(δ13) * Math.cos(φ1), Math.cos(δ13) - Math.sin(φ1) * Math.sin(φ3));
|
||||
var λ3 = λ1 + Δλ13;
|
||||
return new L__namespace.LatLng(this.toDegrees(φ3), this.toDegrees(λ3));
|
||||
};
|
||||
GeodesicCore.prototype.midpoint = function (start, dest) {
|
||||
// φm = atan2( sinφ1 + sinφ2, √( (cosφ1 + cosφ2⋅cosΔλ)² + cos²φ2⋅sin²Δλ ) )
|
||||
// λm = λ1 + atan2(cosφ2⋅sinΔλ, cosφ1 + cosφ2⋅cosΔλ)
|
||||
// midpoint is sum of vectors to two points: mathforum.org/library/drmath/view/51822.html
|
||||
var φ1 = this.toRadians(start.lat);
|
||||
var λ1 = this.toRadians(start.lng);
|
||||
var φ2 = this.toRadians(dest.lat);
|
||||
var Δλ = this.toRadians(dest.lng - start.lng);
|
||||
// get cartesian coordinates for the two points
|
||||
var A = { x: Math.cos(φ1), y: 0, z: Math.sin(φ1) }; // place point A on prime meridian y=0
|
||||
var B = { x: Math.cos(φ2) * Math.cos(Δλ), y: Math.cos(φ2) * Math.sin(Δλ), z: Math.sin(φ2) };
|
||||
// vector to midpoint is sum of vectors to two points (no need to normalise)
|
||||
var C = { x: A.x + B.x, y: A.y + B.y, z: A.z + B.z };
|
||||
var φm = Math.atan2(C.z, Math.sqrt(C.x * C.x + C.y * C.y));
|
||||
var λm = λ1 + Math.atan2(C.y, C.x);
|
||||
return new L__namespace.LatLng(this.toDegrees(φm), this.toDegrees(λm));
|
||||
};
|
||||
return GeodesicCore;
|
||||
}());
|
||||
|
||||
var GeodesicGeometry = /** @class */ (function () {
|
||||
function GeodesicGeometry(options) {
|
||||
var _a;
|
||||
this.geodesic = new GeodesicCore();
|
||||
this.steps = (_a = options === null || options === void 0 ? void 0 : options.steps) !== null && _a !== void 0 ? _a : 3;
|
||||
}
|
||||
/**
|
||||
* A geodesic line between `start` and `dest` is created with this recursive function.
|
||||
* It calculates the geodesic midpoint between `start` and `dest` and uses this midpoint to call itself again (twice!).
|
||||
* The results are then merged into one continuous linestring.
|
||||
*
|
||||
* The number of resulting vertices (incl. `start` and `dest`) depends on the initial value for `iterations`
|
||||
* and can be calculated with: vertices == 1 + 2 ** (initialIterations + 1)
|
||||
*
|
||||
* As this is an exponential function, be extra careful to limit the initial value for `iterations` (8 results in 513 vertices).
|
||||
*
|
||||
* @param start start position
|
||||
* @param dest destination
|
||||
* @param iterations
|
||||
* @return resulting linestring
|
||||
*/
|
||||
GeodesicGeometry.prototype.recursiveMidpoint = function (start, dest, iterations) {
|
||||
var geom = [start, dest];
|
||||
var midpoint = this.geodesic.midpoint(start, dest);
|
||||
if (iterations > 0) {
|
||||
geom.splice.apply(geom, __spreadArray([0, 1], this.recursiveMidpoint(start, midpoint, iterations - 1), false));
|
||||
geom.splice.apply(geom, __spreadArray([geom.length - 2, 2], this.recursiveMidpoint(midpoint, dest, iterations - 1), false));
|
||||
}
|
||||
else {
|
||||
geom.splice(1, 0, midpoint);
|
||||
}
|
||||
return geom;
|
||||
};
|
||||
/**
|
||||
* This is the wrapper-function to generate a geodesic line. It's just for future backwards-compatibility
|
||||
* if there is another algorithm used to create the actual line.
|
||||
*
|
||||
* The `steps`-property is used to define the number of resulting vertices of the linestring: vertices == 1 + 2 ** (steps + 1)
|
||||
* The value for `steps` is currently limited to 8 (513 vertices) for performance reasons until another algorithm is found.
|
||||
*
|
||||
* @param start start position
|
||||
* @param dest destination
|
||||
* @return resulting linestring
|
||||
*/
|
||||
GeodesicGeometry.prototype.line = function (start, dest) {
|
||||
return this.recursiveMidpoint(start, dest, Math.min(8, this.steps));
|
||||
};
|
||||
GeodesicGeometry.prototype.multiLineString = function (latlngs) {
|
||||
var multiLineString = [];
|
||||
for (var _i = 0, latlngs_1 = latlngs; _i < latlngs_1.length; _i++) {
|
||||
var linestring = latlngs_1[_i];
|
||||
var segment = [];
|
||||
for (var j = 1; j < linestring.length; j++) {
|
||||
segment.splice.apply(segment, __spreadArray([segment.length - 1, 1], this.line(linestring[j - 1], linestring[j]), false));
|
||||
}
|
||||
multiLineString.push(segment);
|
||||
}
|
||||
return multiLineString;
|
||||
};
|
||||
GeodesicGeometry.prototype.lineString = function (latlngs) {
|
||||
return this.multiLineString([latlngs])[0];
|
||||
};
|
||||
/**
|
||||
*
|
||||
* Is much (10x) faster than the previous implementation:
|
||||
*
|
||||
* ```
|
||||
* Benchmark (no split): splitLine x 459,044 ops/sec ±0.53% (95 runs sampled)
|
||||
* Benchmark (split): splitLine x 42,999 ops/sec ±0.51% (97 runs sampled)
|
||||
* ```
|
||||
*
|
||||
* @param startPosition
|
||||
* @param destPosition
|
||||
*/
|
||||
GeodesicGeometry.prototype.splitLine = function (startPosition, destPosition) {
|
||||
var antimeridianWest = {
|
||||
point: new L__namespace.LatLng(89.9, -180.0000001),
|
||||
bearing: 180
|
||||
};
|
||||
var antimeridianEast = {
|
||||
point: new L__namespace.LatLng(89.9, 180.0000001),
|
||||
bearing: 180
|
||||
};
|
||||
// make a copy to work with
|
||||
var start = new L__namespace.LatLng(startPosition.lat, startPosition.lng, startPosition.alt);
|
||||
var dest = new L__namespace.LatLng(destPosition.lat, destPosition.lng, destPosition.alt);
|
||||
start.lng = this.geodesic.wrap(start.lng, 360);
|
||||
dest.lng = this.geodesic.wrap(dest.lng, 360);
|
||||
if (dest.lng - start.lng > 180) {
|
||||
dest.lng = dest.lng - 360;
|
||||
}
|
||||
else if (dest.lng - start.lng < -180) {
|
||||
dest.lng = dest.lng + 360;
|
||||
}
|
||||
var result = [
|
||||
[
|
||||
new L__namespace.LatLng(start.lat, this.geodesic.wrap(start.lng, 180), start.alt),
|
||||
new L__namespace.LatLng(dest.lat, this.geodesic.wrap(dest.lng, 180), dest.alt)
|
||||
]
|
||||
];
|
||||
// crossing antimeridian from "this" side?
|
||||
if (start.lng >= -180 && start.lng <= 180) {
|
||||
// crossing the "western" antimeridian
|
||||
if (dest.lng < -180) {
|
||||
var bearing = this.geodesic.inverse(start, dest).initialBearing;
|
||||
var intersection = this.geodesic.intersection(start, bearing, antimeridianWest.point, antimeridianWest.bearing);
|
||||
if (intersection) {
|
||||
result = [
|
||||
[start, intersection],
|
||||
[
|
||||
new L__namespace.LatLng(intersection.lat, intersection.lng + 360),
|
||||
new L__namespace.LatLng(dest.lat, dest.lng + 360, dest.alt)
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
// crossing the "eastern" antimeridian
|
||||
else if (dest.lng > 180) {
|
||||
var bearing = this.geodesic.inverse(start, dest).initialBearing;
|
||||
var intersection = this.geodesic.intersection(start, bearing, antimeridianEast.point, antimeridianEast.bearing);
|
||||
if (intersection) {
|
||||
result = [
|
||||
[start, intersection],
|
||||
[
|
||||
new L__namespace.LatLng(intersection.lat, intersection.lng - 360),
|
||||
new L__namespace.LatLng(dest.lat, dest.lng - 360, dest.alt)
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
// coming back over the antimeridian from the "other" side?
|
||||
else if (dest.lng >= -180 && dest.lng <= 180) {
|
||||
// crossing the "western" antimeridian
|
||||
if (start.lng < -180) {
|
||||
var bearing = this.geodesic.inverse(start, dest).initialBearing;
|
||||
var intersection = this.geodesic.intersection(start, bearing, antimeridianWest.point, antimeridianWest.bearing);
|
||||
if (intersection) {
|
||||
result = [
|
||||
[
|
||||
new L__namespace.LatLng(start.lat, start.lng + 360, start.alt),
|
||||
new L__namespace.LatLng(intersection.lat, intersection.lng + 360)
|
||||
],
|
||||
[intersection, dest]
|
||||
];
|
||||
}
|
||||
}
|
||||
// crossing the "eastern" antimeridian
|
||||
else if (start.lng > 180) {
|
||||
var bearing = this.geodesic.inverse(start, dest).initialBearing;
|
||||
var intersection = this.geodesic.intersection(start, bearing, antimeridianWest.point, antimeridianWest.bearing);
|
||||
if (intersection) {
|
||||
result = [
|
||||
[
|
||||
new L__namespace.LatLng(start.lat, start.lng - 360, start.alt),
|
||||
new L__namespace.LatLng(intersection.lat, intersection.lng - 360)
|
||||
],
|
||||
[intersection, dest]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Linestrings of a given multilinestring that cross the antimeridian will be split in two separate linestrings.
|
||||
* This function is used to wrap lines around when they cross the antimeridian
|
||||
* It iterates over all linestrings and reconstructs the step-by-step if no split is needed.
|
||||
* In case the line was split, the linestring ends at the antimeridian and a new linestring is created for the
|
||||
* remaining points of the original linestring.
|
||||
*
|
||||
* @param multilinestring
|
||||
* @return another multilinestring where segments crossing the antimeridian are split
|
||||
*/
|
||||
GeodesicGeometry.prototype.splitMultiLineString = function (multilinestring) {
|
||||
var result = [];
|
||||
for (var _i = 0, multilinestring_1 = multilinestring; _i < multilinestring_1.length; _i++) {
|
||||
var linestring = multilinestring_1[_i];
|
||||
if (linestring.length === 1) {
|
||||
result.push(linestring); // just a single point in linestring, no need to split
|
||||
continue;
|
||||
}
|
||||
var segment = [];
|
||||
for (var j = 1; j < linestring.length; j++) {
|
||||
var split = this.splitLine(linestring[j - 1], linestring[j]);
|
||||
segment.pop();
|
||||
segment = segment.concat(split[0]);
|
||||
if (split.length > 1) {
|
||||
result.push(segment); // the line was split, so we end the linestring right here
|
||||
segment = split[1]; // begin the new linestring with the second part of the split line
|
||||
}
|
||||
}
|
||||
result.push(segment);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Linestrings of a given multilinestring will be wrapped (+- 360°) to show a continuous line w/o any weird discontinuities
|
||||
* when `wrap` is set to `false` in the geodesic class
|
||||
* @param multilinestring
|
||||
* @returns another multilinestring where the points of each linestring are wrapped accordingly
|
||||
*/
|
||||
GeodesicGeometry.prototype.wrapMultiLineString = function (multilinestring) {
|
||||
var result = [];
|
||||
for (var _i = 0, multilinestring_2 = multilinestring; _i < multilinestring_2.length; _i++) {
|
||||
var linestring = multilinestring_2[_i];
|
||||
var resultLine = [];
|
||||
var previous = null;
|
||||
// iterate over every point and check if it needs to be wrapped
|
||||
for (var _a = 0, linestring_1 = linestring; _a < linestring_1.length; _a++) {
|
||||
var point = linestring_1[_a];
|
||||
if (previous === null) {
|
||||
// the first point is the anchor of the linestring from which the line will always start (w/o any wrapping applied)
|
||||
resultLine.push(new L__namespace.LatLng(point.lat, point.lng));
|
||||
previous = new L__namespace.LatLng(point.lat, point.lng);
|
||||
}
|
||||
else {
|
||||
// I prefer clearly defined branches over a continue-operation.
|
||||
// if the difference between the current and *previous* point is greater than 360°, the current point needs to be shifted
|
||||
// to be on the same 'sphere' as the previous one.
|
||||
var offset = Math.round((point.lng - previous.lng) / 360);
|
||||
// shift the point accordingly and add to the result
|
||||
resultLine.push(new L__namespace.LatLng(point.lat, point.lng - offset * 360));
|
||||
// use the wrapped point as the anchor for the next one
|
||||
previous = new L__namespace.LatLng(point.lat, point.lng - offset * 360); // Need a new object here, to avoid changing the input data
|
||||
}
|
||||
}
|
||||
result.push(resultLine);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Creates a circular (constant radius), closed (1st pos == last pos) geodesic linestring.
|
||||
* The number of vertices is calculated with: `vertices == steps + 1` (where 1st == last)
|
||||
*
|
||||
* @param center
|
||||
* @param radius
|
||||
* @return resulting linestring
|
||||
*/
|
||||
GeodesicGeometry.prototype.circle = function (center, radius) {
|
||||
var vertices = [];
|
||||
for (var i = 0; i < this.steps; i++) {
|
||||
var point = this.geodesic.direct(center, (360 / this.steps) * i, radius);
|
||||
vertices.push(new L__namespace.LatLng(point.lat, point.lng));
|
||||
}
|
||||
// append first vertice to the end to close the linestring
|
||||
vertices.push(new L__namespace.LatLng(vertices[0].lat, vertices[0].lng));
|
||||
return vertices;
|
||||
};
|
||||
/**
|
||||
* Handles splitting of circles at the antimeridian.
|
||||
* @param linestring a linestring that resembles the geodesic circle
|
||||
* @return a multilinestring that consist of one or two linestrings
|
||||
*/
|
||||
GeodesicGeometry.prototype.splitCircle = function (linestring) {
|
||||
var result = this.splitMultiLineString([linestring]);
|
||||
// If the circle was split, it results in exactly three linestrings where first and last
|
||||
// must be re-assembled because they belong to the same "side" of the split circle.
|
||||
if (result.length === 3) {
|
||||
result[2] = __spreadArray(__spreadArray([], result[2], true), result[0], true);
|
||||
result.shift();
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Calculates the distance between two positions on the earths surface
|
||||
* @param start 1st position
|
||||
* @param dest 2nd position
|
||||
* @return the distance in **meters**
|
||||
*/
|
||||
GeodesicGeometry.prototype.distance = function (start, dest) {
|
||||
return this.geodesic.inverse(new L__namespace.LatLng(start.lat, this.geodesic.wrap(start.lng, 180)), new L__namespace.LatLng(dest.lat, this.geodesic.wrap(dest.lng, 180))).distance;
|
||||
};
|
||||
GeodesicGeometry.prototype.multilineDistance = function (multilinestring) {
|
||||
var dist = [];
|
||||
for (var _i = 0, multilinestring_3 = multilinestring; _i < multilinestring_3.length; _i++) {
|
||||
var linestring = multilinestring_3[_i];
|
||||
var segmentDistance = 0;
|
||||
for (var j = 1; j < linestring.length; j++) {
|
||||
segmentDistance += this.distance(linestring[j - 1], linestring[j]);
|
||||
}
|
||||
dist.push(segmentDistance);
|
||||
}
|
||||
return dist;
|
||||
};
|
||||
GeodesicGeometry.prototype.updateStatistics = function (points, vertices) {
|
||||
var stats = { distanceArray: [], totalDistance: 0, points: 0, vertices: 0 };
|
||||
stats.distanceArray = this.multilineDistance(points);
|
||||
stats.totalDistance = stats.distanceArray.reduce(function (x, y) { return x + y; }, 0);
|
||||
stats.points = 0;
|
||||
for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
|
||||
var item = points_1[_i];
|
||||
stats.points += item.reduce(function (x) { return x + 1; }, 0);
|
||||
}
|
||||
stats.vertices = 0;
|
||||
for (var _a = 0, vertices_1 = vertices; _a < vertices_1.length; _a++) {
|
||||
var item = vertices_1[_a];
|
||||
stats.vertices += item.reduce(function (x) { return x + 1; }, 0);
|
||||
}
|
||||
return stats;
|
||||
};
|
||||
return GeodesicGeometry;
|
||||
}());
|
||||
|
||||
function instanceOfLatLngLiteral(object) {
|
||||
return ((typeof object === "object")
|
||||
&& (object !== null)
|
||||
&& ("lat" in object)
|
||||
&& ("lng" in object)
|
||||
&& (typeof object.lat === "number")
|
||||
&& (typeof object.lng === "number"));
|
||||
}
|
||||
function instanceOfLatLngTuple(object) {
|
||||
return ((object instanceof Array)
|
||||
&& (typeof object[0] === "number")
|
||||
&& (typeof object[1] === "number"));
|
||||
}
|
||||
function instanceOfLatLngExpression(object) {
|
||||
return object instanceof L__namespace.LatLng || instanceOfLatLngTuple(object) || instanceOfLatLngLiteral(object);
|
||||
}
|
||||
function latlngExpressiontoLatLng(input) {
|
||||
if (input instanceof L__namespace.LatLng) {
|
||||
return input;
|
||||
}
|
||||
else if (instanceOfLatLngTuple(input)) {
|
||||
return new L__namespace.LatLng(input[0], input[1], input.at(2)); // alt is optional
|
||||
}
|
||||
else if (instanceOfLatLngLiteral(input)) {
|
||||
return new L__namespace.LatLng(input.lat, input.lng, input.alt);
|
||||
}
|
||||
throw new Error("L.LatLngExpression expected. Unknown object found.");
|
||||
}
|
||||
function latlngExpressionArraytoLatLngArray(input) {
|
||||
var latlng = [];
|
||||
var iterateOver = instanceOfLatLngExpression(input[0]) ? [input] : input;
|
||||
var unknownObjectError = new Error("L.LatLngExpression[] | L.LatLngExpression[][] expected. Unknown object found.");
|
||||
if (!(iterateOver instanceof Array)) {
|
||||
throw unknownObjectError;
|
||||
}
|
||||
for (var _i = 0, _a = iterateOver; _i < _a.length; _i++) {
|
||||
var group = _a[_i];
|
||||
if (!(group instanceof Array)) {
|
||||
throw unknownObjectError;
|
||||
}
|
||||
var sub = [];
|
||||
for (var _b = 0, group_1 = group; _b < group_1.length; _b++) {
|
||||
var point = group_1[_b];
|
||||
if (!instanceOfLatLngExpression(point)) {
|
||||
throw unknownObjectError;
|
||||
}
|
||||
sub.push(latlngExpressiontoLatLng(point));
|
||||
}
|
||||
latlng.push(sub);
|
||||
}
|
||||
return latlng;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw geodesic lines based on L.Polyline
|
||||
*/
|
||||
var GeodesicLine = /** @class */ (function (_super) {
|
||||
__extends(GeodesicLine, _super);
|
||||
function GeodesicLine(latlngs, options) {
|
||||
var _this = _super.call(this, [], options) || this;
|
||||
/** these should be good for most use-cases */
|
||||
_this.defaultOptions = { wrap: true, steps: 3 };
|
||||
/** use this if you need some detailled info about the current geometry */
|
||||
_this.statistics = { distanceArray: [], totalDistance: 0, points: 0, vertices: 0 };
|
||||
/** stores all positions that are used to create the geodesic line */
|
||||
_this.points = [];
|
||||
L__namespace.Util.setOptions(_this, __assign(__assign({}, _this.defaultOptions), options));
|
||||
_this.geom = new GeodesicGeometry(_this.options);
|
||||
if (latlngs !== undefined) {
|
||||
_this.setLatLngs(latlngs);
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
/** calculates the geodesics and update the polyline-object accordingly */
|
||||
GeodesicLine.prototype.updateGeometry = function () {
|
||||
var geodesic = [];
|
||||
geodesic = this.geom.multiLineString(this.points);
|
||||
this.statistics = this.geom.updateStatistics(this.points, geodesic);
|
||||
if (this.options.wrap) {
|
||||
var split = this.geom.splitMultiLineString(geodesic);
|
||||
_super.prototype.setLatLngs.call(this, split);
|
||||
}
|
||||
else {
|
||||
_super.prototype.setLatLngs.call(this, this.geom.wrapMultiLineString(geodesic));
|
||||
}
|
||||
};
|
||||
/**
|
||||
* overwrites the original function with additional functionality to create a geodesic line
|
||||
* @param latlngs an array (or 2d-array) of positions
|
||||
*/
|
||||
GeodesicLine.prototype.setLatLngs = function (latlngs) {
|
||||
this.points = latlngExpressionArraytoLatLngArray(latlngs);
|
||||
this.updateGeometry();
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* add a given point to the geodesic line object
|
||||
* @param latlng point to add. The point will always be added to the last linestring of a multiline
|
||||
* @param latlngs define a linestring to add the new point to. Read from points-property before (e.g. `line.addLatLng(Beijing, line.points[0]);`)
|
||||
*/
|
||||
GeodesicLine.prototype.addLatLng = function (latlng, latlngs) {
|
||||
var point = latlngExpressiontoLatLng(latlng);
|
||||
if (this.points.length === 0) {
|
||||
this.points.push([point]);
|
||||
}
|
||||
else if (latlngs === undefined) {
|
||||
this.points[this.points.length - 1].push(point);
|
||||
}
|
||||
else {
|
||||
latlngs.push(point);
|
||||
}
|
||||
this.updateGeometry();
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* Creates geodesic lines from a given GeoJSON-Object.
|
||||
* @param input GeoJSON-Object
|
||||
*/
|
||||
GeodesicLine.prototype.fromGeoJson = function (input) {
|
||||
var latlngs = [];
|
||||
var features = [];
|
||||
if (input.type === "FeatureCollection") {
|
||||
features = input.features;
|
||||
}
|
||||
else if (input.type === "Feature") {
|
||||
features = [input];
|
||||
}
|
||||
else if (["MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"].includes(input.type)) {
|
||||
features = [
|
||||
{
|
||||
type: "Feature",
|
||||
geometry: input,
|
||||
properties: {}
|
||||
}
|
||||
];
|
||||
}
|
||||
else {
|
||||
console.log("[Leaflet.Geodesic] fromGeoJson() - Type \"".concat(input.type, "\" not supported."));
|
||||
}
|
||||
features.forEach(function (feature) {
|
||||
switch (feature.geometry.type) {
|
||||
case "MultiPoint":
|
||||
case "LineString":
|
||||
latlngs = __spreadArray(__spreadArray([], latlngs, true), [L__namespace.GeoJSON.coordsToLatLngs(feature.geometry.coordinates, 0)], false);
|
||||
break;
|
||||
case "MultiLineString":
|
||||
case "Polygon":
|
||||
latlngs = __spreadArray(__spreadArray([], latlngs, true), L__namespace.GeoJSON.coordsToLatLngs(feature.geometry.coordinates, 1), true);
|
||||
break;
|
||||
case "MultiPolygon":
|
||||
feature.geometry.coordinates.forEach(function (item) {
|
||||
latlngs = __spreadArray(__spreadArray([], latlngs, true), L__namespace.GeoJSON.coordsToLatLngs(item, 1), true);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
console.log("[Leaflet.Geodesic] fromGeoJson() - Type \"".concat(feature.geometry.type, "\" not supported."));
|
||||
}
|
||||
});
|
||||
if (latlngs.length) {
|
||||
this.setLatLngs(latlngs);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* Calculates the distance between two geo-positions
|
||||
* @param start 1st position
|
||||
* @param dest 2nd position
|
||||
* @return the distance in meters
|
||||
*/
|
||||
GeodesicLine.prototype.distance = function (start, dest) {
|
||||
return this.geom.distance(latlngExpressiontoLatLng(start), latlngExpressiontoLatLng(dest));
|
||||
};
|
||||
return GeodesicLine;
|
||||
}(L__namespace.Polyline));
|
||||
|
||||
/**
|
||||
* Can be used to create a geodesic circle based on L.Polyline
|
||||
*/
|
||||
var GeodesicCircleClass = /** @class */ (function (_super) {
|
||||
__extends(GeodesicCircleClass, _super);
|
||||
function GeodesicCircleClass(center, options) {
|
||||
var _a;
|
||||
var _this = _super.call(this, [], options) || this;
|
||||
_this.defaultOptions = { wrap: true, steps: 24, fill: true, noClip: true };
|
||||
_this.statistics = { distanceArray: [], totalDistance: 0, points: 0, vertices: 0 };
|
||||
L__namespace.Util.setOptions(_this, __assign(__assign({}, _this.defaultOptions), options));
|
||||
// merge/set options
|
||||
var extendedOptions = _this.options;
|
||||
_this.radius = (_a = extendedOptions.radius) !== null && _a !== void 0 ? _a : 1000 * 1000;
|
||||
_this.center = center === undefined ? new L__namespace.LatLng(0, 0) : latlngExpressiontoLatLng(center);
|
||||
_this.geom = new GeodesicGeometry(_this.options);
|
||||
// update the geometry
|
||||
_this.update();
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Updates the geometry and re-calculates some statistics
|
||||
*/
|
||||
GeodesicCircleClass.prototype.update = function () {
|
||||
var circle = this.geom.circle(this.center, this.radius);
|
||||
this.statistics = this.geom.updateStatistics([[this.center]], [circle]);
|
||||
// circumfence must be re-calculated from geodesic
|
||||
this.statistics.totalDistance = this.geom.multilineDistance([circle]).reduce(function (x, y) { return x + y; }, 0);
|
||||
if (this.options.wrap) {
|
||||
var split = this.geom.splitCircle(circle);
|
||||
_super.prototype.setLatLngs.call(this, split);
|
||||
}
|
||||
else {
|
||||
_super.prototype.setLatLngs.call(this, circle);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Calculate the distance between the current center and an arbitrary position.
|
||||
* @param latlng geo-position to calculate distance to
|
||||
* @return distance in meters
|
||||
*/
|
||||
GeodesicCircleClass.prototype.distanceTo = function (latlng) {
|
||||
var dest = latlngExpressiontoLatLng(latlng);
|
||||
return this.geom.distance(this.center, dest);
|
||||
};
|
||||
/**
|
||||
* Set a new center for the geodesic circle and update the geometry. Radius may also be set.
|
||||
* @param center the new center
|
||||
* @param radius the new radius
|
||||
*/
|
||||
GeodesicCircleClass.prototype.setLatLng = function (center, radius) {
|
||||
this.center = latlngExpressiontoLatLng(center);
|
||||
this.radius = radius !== null && radius !== void 0 ? radius : this.radius;
|
||||
this.update();
|
||||
};
|
||||
/**
|
||||
* Set a new radius for the geodesic circle and update the geometry. Center may also be set.
|
||||
* @param radius the new radius
|
||||
* @param center the new center
|
||||
*/
|
||||
GeodesicCircleClass.prototype.setRadius = function (radius, center) {
|
||||
this.radius = radius;
|
||||
this.center = center ? latlngExpressiontoLatLng(center) : this.center;
|
||||
this.update();
|
||||
};
|
||||
return GeodesicCircleClass;
|
||||
}(L__namespace.Polyline));
|
||||
|
||||
if (typeof window.L !== "undefined") {
|
||||
window.L.Geodesic = GeodesicLine;
|
||||
window.L.geodesic = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return new (GeodesicLine.bind.apply(GeodesicLine, __spreadArray([void 0], args, false)))();
|
||||
};
|
||||
window.L.GeodesicCircle = GeodesicCircleClass;
|
||||
window.L.geodesiccircle = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return new (GeodesicCircleClass.bind.apply(GeodesicCircleClass, __spreadArray([void 0], args, false)))();
|
||||
};
|
||||
}
|
||||
|
||||
exports.GeodesicCircleClass = GeodesicCircleClass;
|
||||
exports.GeodesicLine = GeodesicLine;
|
||||
921
node_modules/leaflet.geodesic/dist/leaflet.geodesic.umd.js
generated
vendored
Normal file
921
node_modules/leaflet.geodesic/dist/leaflet.geodesic.umd.js
generated
vendored
Normal file
|
|
@ -0,0 +1,921 @@
|
|||
/*! leaflet.geodesic 2.7.1 - (c) Henry Thasler - https://github.com/henrythasler/Leaflet.Geodesic#readme */
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('leaflet')) :
|
||||
typeof define === 'function' && define.amd ? define(['exports', 'leaflet'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.L = global.L || {}, global.L.geodesic = {}), global.L));
|
||||
})(this, (function (exports, L) { 'use strict';
|
||||
|
||||
function _interopNamespaceDefault(e) {
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n.default = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var L__namespace = /*#__PURE__*/_interopNamespaceDefault(L);
|
||||
|
||||
/******************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
/* global Reflect, Promise, SuppressedError, Symbol */
|
||||
|
||||
var extendStatics = function(d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
|
||||
function __extends(d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
}
|
||||
|
||||
var __assign = function() {
|
||||
__assign = Object.assign || function __assign(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
|
||||
function __spreadArray(to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
}
|
||||
|
||||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
};
|
||||
|
||||
var GeodesicCore = /** @class */ (function () {
|
||||
function GeodesicCore(options) {
|
||||
this.options = { wrap: true, steps: 3 };
|
||||
this.ellipsoid = {
|
||||
a: 6378137,
|
||||
b: 6356752.3142,
|
||||
f: 1 / 298.257223563
|
||||
}; // WGS-84
|
||||
this.options = __assign(__assign({}, this.options), options);
|
||||
}
|
||||
GeodesicCore.prototype.toRadians = function (degree) {
|
||||
return (degree * Math.PI) / 180;
|
||||
};
|
||||
GeodesicCore.prototype.toDegrees = function (radians) {
|
||||
return (radians * 180) / Math.PI;
|
||||
};
|
||||
/**
|
||||
* implements scientific modulus
|
||||
* source: http://www.codeavenger.com/2017/05/19/JavaScript-Modulo-operation-and-the-Caesar-Cipher.html
|
||||
* @param n
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
GeodesicCore.prototype.mod = function (n, p) {
|
||||
var r = n % p;
|
||||
return r < 0 ? r + p : r;
|
||||
};
|
||||
/**
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/dms.js
|
||||
* @param degrees arbitrary value
|
||||
* @return degrees between 0..360
|
||||
*/
|
||||
GeodesicCore.prototype.wrap360 = function (degrees) {
|
||||
if (0 <= degrees && degrees < 360) {
|
||||
return degrees; // avoid rounding due to arithmetic ops if within range
|
||||
}
|
||||
else {
|
||||
return this.mod(degrees, 360);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* general wrap function with arbitrary max value
|
||||
* @param degrees arbitrary value
|
||||
* @param max
|
||||
* @return degrees between `-max`..`+max`
|
||||
*/
|
||||
GeodesicCore.prototype.wrap = function (degrees, max) {
|
||||
if (max === void 0) { max = 360; }
|
||||
if (-max <= degrees && degrees <= max) {
|
||||
return degrees;
|
||||
}
|
||||
else {
|
||||
return this.mod(degrees + max, 2 * max) - max;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Vincenty direct calculation.
|
||||
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-ellipsoidal-vincenty.js
|
||||
*
|
||||
* @param start starting point
|
||||
* @param bearing initial bearing (in degrees)
|
||||
* @param distance distance from starting point to calculate along given bearing in meters.
|
||||
* @param maxInterations How many iterations can be made to reach the allowed deviation (`ε`), before an error will be thrown.
|
||||
* @return Final point (destination point) and bearing (in degrees)
|
||||
*/
|
||||
GeodesicCore.prototype.direct = function (start, bearing, distance, maxInterations) {
|
||||
if (maxInterations === void 0) { maxInterations = 100; }
|
||||
var φ1 = this.toRadians(start.lat);
|
||||
var λ1 = this.toRadians(start.lng);
|
||||
var α1 = this.toRadians(bearing);
|
||||
var s = distance;
|
||||
var ε = Number.EPSILON * 1000;
|
||||
var _a = this.ellipsoid, a = _a.a, b = _a.b, f = _a.f;
|
||||
var sinα1 = Math.sin(α1);
|
||||
var cosα1 = Math.cos(α1);
|
||||
var tanU1 = (1 - f) * Math.tan(φ1), cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1), sinU1 = tanU1 * cosU1;
|
||||
var σ1 = Math.atan2(tanU1, cosα1); // σ1 = angular distance on the sphere from the equator to P1
|
||||
var sinα = cosU1 * sinα1; // α = azimuth of the geodesic at the equator
|
||||
var cosSqα = 1 - sinα * sinα;
|
||||
var uSq = (cosSqα * (a * a - b * b)) / (b * b);
|
||||
var A = 1 + (uSq / 16384) * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
||||
var B = (uSq / 1024) * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
||||
var σ = s / (b * A), sinσ = null, cosσ = null, Δσ = null; // σ = angular distance P₁ P₂ on the sphere
|
||||
var cos2σₘ = null; // σₘ = angular distance on the sphere from the equator to the midpoint of the line
|
||||
var σʹ = null, iterations = 0;
|
||||
do {
|
||||
cos2σₘ = Math.cos(2 * σ1 + σ);
|
||||
sinσ = Math.sin(σ);
|
||||
cosσ = Math.cos(σ);
|
||||
Δσ =
|
||||
B *
|
||||
sinσ *
|
||||
(cos2σₘ +
|
||||
(B / 4) *
|
||||
(cosσ * (-1 + 2 * cos2σₘ * cos2σₘ) -
|
||||
(B / 6) * cos2σₘ * (-3 + 4 * sinσ * sinσ) * (-3 + 4 * cos2σₘ * cos2σₘ)));
|
||||
σʹ = σ;
|
||||
σ = s / (b * A) + Δσ;
|
||||
} while (Math.abs(σ - σʹ) > ε && ++iterations < maxInterations);
|
||||
if (iterations >= maxInterations) {
|
||||
throw new EvalError("Direct vincenty formula failed to converge after ".concat(maxInterations, " iterations \n (start=").concat(start.lat, "/").concat(start.lng, "; bearing=").concat(bearing, "; distance=").concat(distance, ")")); // not possible?
|
||||
}
|
||||
var x = sinU1 * sinσ - cosU1 * cosσ * cosα1;
|
||||
var φ2 = Math.atan2(sinU1 * cosσ + cosU1 * sinσ * cosα1, (1 - f) * Math.sqrt(sinα * sinα + x * x));
|
||||
var λ = Math.atan2(sinσ * sinα1, cosU1 * cosσ - sinU1 * sinσ * cosα1);
|
||||
var C = (f / 16) * cosSqα * (4 + f * (4 - 3 * cosSqα));
|
||||
var dL = λ - (1 - C) * f * sinα * (σ + C * sinσ * (cos2σₘ + C * cosσ * (-1 + 2 * cos2σₘ * cos2σₘ)));
|
||||
var λ2 = λ1 + dL;
|
||||
var α2 = Math.atan2(sinα, -x);
|
||||
return {
|
||||
lat: this.toDegrees(φ2),
|
||||
lng: this.toDegrees(λ2),
|
||||
bearing: this.wrap360(this.toDegrees(α2))
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Vincenty inverse calculation.
|
||||
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-ellipsoidal-vincenty.js
|
||||
*
|
||||
* @param start Latitude/longitude of starting point.
|
||||
* @param dest Latitude/longitude of destination point.
|
||||
* @return Object including distance, initialBearing, finalBearing.
|
||||
*/
|
||||
GeodesicCore.prototype.inverse = function (start, dest, maxInterations, mitigateConvergenceError) {
|
||||
if (maxInterations === void 0) { maxInterations = 100; }
|
||||
if (mitigateConvergenceError === void 0) { mitigateConvergenceError = true; }
|
||||
var p1 = start, p2 = dest;
|
||||
var φ1 = this.toRadians(p1.lat), λ1 = this.toRadians(p1.lng);
|
||||
var φ2 = this.toRadians(p2.lat), λ2 = this.toRadians(p2.lng);
|
||||
var π = Math.PI;
|
||||
var ε = Number.EPSILON;
|
||||
// allow alternative ellipsoid to be specified
|
||||
var _a = this.ellipsoid, a = _a.a, b = _a.b, f = _a.f;
|
||||
var dL = λ2 - λ1; // L = difference in longitude, U = reduced latitude, defined by tan U = (1-f)·tanφ.
|
||||
var tanU1 = (1 - f) * Math.tan(φ1), cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1), sinU1 = tanU1 * cosU1;
|
||||
var tanU2 = (1 - f) * Math.tan(φ2), cosU2 = 1 / Math.sqrt(1 + tanU2 * tanU2), sinU2 = tanU2 * cosU2;
|
||||
var antipodal = Math.abs(dL) > π / 2 || Math.abs(φ2 - φ1) > π / 2;
|
||||
var λ = dL, sinλ = null, cosλ = null; // λ = difference in longitude on an auxiliary sphere
|
||||
var σ = antipodal ? π : 0, sinσ = 0, cosσ = antipodal ? -1 : 1, sinSqσ = null; // σ = angular distance P₁ P₂ on the sphere
|
||||
var cos2σₘ = 1; // σₘ = angular distance on the sphere from the equator to the midpoint of the line
|
||||
var sinα = null, cosSqα = 1; // α = azimuth of the geodesic at the equator
|
||||
var C = null;
|
||||
var λʹ = null, iterations = 0;
|
||||
do {
|
||||
sinλ = Math.sin(λ);
|
||||
cosλ = Math.cos(λ);
|
||||
sinSqσ =
|
||||
cosU2 * sinλ * (cosU2 * sinλ) +
|
||||
(cosU1 * sinU2 - sinU1 * cosU2 * cosλ) * (cosU1 * sinU2 - sinU1 * cosU2 * cosλ);
|
||||
if (Math.abs(sinSqσ) < ε) {
|
||||
break; // co-incident/antipodal points (falls back on λ/σ = L)
|
||||
}
|
||||
sinσ = Math.sqrt(sinSqσ);
|
||||
cosσ = sinU1 * sinU2 + cosU1 * cosU2 * cosλ;
|
||||
σ = Math.atan2(sinσ, cosσ);
|
||||
sinα = (cosU1 * cosU2 * sinλ) / sinσ;
|
||||
cosSqα = 1 - sinα * sinα;
|
||||
cos2σₘ = cosSqα !== 0 ? cosσ - (2 * sinU1 * sinU2) / cosSqα : 0; // on equatorial line cos²α = 0 (§6)
|
||||
C = (f / 16) * cosSqα * (4 + f * (4 - 3 * cosSqα));
|
||||
λʹ = λ;
|
||||
λ = dL + (1 - C) * f * sinα * (σ + C * sinσ * (cos2σₘ + C * cosσ * (-1 + 2 * cos2σₘ * cos2σₘ)));
|
||||
var iterationCheck = antipodal ? Math.abs(λ) - π : Math.abs(λ);
|
||||
if (iterationCheck > π) {
|
||||
throw new EvalError("λ > π");
|
||||
}
|
||||
} while (Math.abs(λ - λʹ) > 1e-12 && ++iterations < maxInterations);
|
||||
if (iterations >= maxInterations) {
|
||||
if (mitigateConvergenceError) {
|
||||
return this.inverse(start, new L__namespace.LatLng(dest.lat, dest.lng - 0.01), maxInterations, mitigateConvergenceError);
|
||||
}
|
||||
else {
|
||||
throw new EvalError("Inverse vincenty formula failed to converge after ".concat(maxInterations, " iterations \n (start=").concat(start.lat, "/").concat(start.lng, "; dest=").concat(dest.lat, "/").concat(dest.lng, ")"));
|
||||
}
|
||||
}
|
||||
var uSq = (cosSqα * (a * a - b * b)) / (b * b);
|
||||
var A = 1 + (uSq / 16384) * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
||||
var B = (uSq / 1024) * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
||||
var Δσ = B *
|
||||
sinσ *
|
||||
(cos2σₘ +
|
||||
(B / 4) *
|
||||
(cosσ * (-1 + 2 * cos2σₘ * cos2σₘ) -
|
||||
(B / 6) * cos2σₘ * (-3 + 4 * sinσ * sinσ) * (-3 + 4 * cos2σₘ * cos2σₘ)));
|
||||
var s = b * A * (σ - Δσ); // s = length of the geodesic
|
||||
// note special handling of exactly antipodal points where sin²σ = 0 (due to discontinuity
|
||||
// atan2(0, 0) = 0 but atan2(this.ε, 0) = π/2 / 90°) - in which case bearing is always meridional,
|
||||
// due north (or due south!)
|
||||
// α = azimuths of the geodesic; α2 the direction P₁ P₂ produced
|
||||
var α1 = Math.abs(sinSqσ) < ε ? 0 : Math.atan2(cosU2 * sinλ, cosU1 * sinU2 - sinU1 * cosU2 * cosλ);
|
||||
var α2 = Math.abs(sinSqσ) < ε ? π : Math.atan2(cosU1 * sinλ, -sinU1 * cosU2 + cosU1 * sinU2 * cosλ);
|
||||
return {
|
||||
distance: s,
|
||||
initialBearing: Math.abs(s) < ε ? NaN : this.wrap360(this.toDegrees(α1)),
|
||||
finalBearing: Math.abs(s) < ε ? NaN : this.wrap360(this.toDegrees(α2))
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Returns the point of intersection of two paths defined by position and bearing.
|
||||
* This calculation uses a spherical model of the earth. This will lead to small errors compared to an ellipsiod model.
|
||||
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
|
||||
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-spherical.js
|
||||
*
|
||||
* @param firstPos 1st path: position and bearing
|
||||
* @param firstBearing
|
||||
* @param secondPos 2nd path: position and bearing
|
||||
* @param secondBearing
|
||||
*/
|
||||
GeodesicCore.prototype.intersection = function (firstPos, firstBearing, secondPos, secondBearing) {
|
||||
var φ1 = this.toRadians(firstPos.lat);
|
||||
var λ1 = this.toRadians(firstPos.lng);
|
||||
var φ2 = this.toRadians(secondPos.lat);
|
||||
var λ2 = this.toRadians(secondPos.lng);
|
||||
var θ13 = this.toRadians(firstBearing);
|
||||
var θ23 = this.toRadians(secondBearing);
|
||||
var Δφ = φ2 - φ1, Δλ = λ2 - λ1;
|
||||
var π = Math.PI;
|
||||
var ε = Number.EPSILON;
|
||||
// angular distance p1-p2
|
||||
var δ12 = 2 *
|
||||
Math.asin(Math.sqrt(Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
|
||||
Math.cos(φ1) * Math.cos(φ2) * Math.sin(Δλ / 2) * Math.sin(Δλ / 2)));
|
||||
if (Math.abs(δ12) < ε) {
|
||||
return firstPos; // coincident points
|
||||
}
|
||||
// initial/final bearings between points
|
||||
var cosθa = (Math.sin(φ2) - Math.sin(φ1) * Math.cos(δ12)) / (Math.sin(δ12) * Math.cos(φ1));
|
||||
var cosθb = (Math.sin(φ1) - Math.sin(φ2) * Math.cos(δ12)) / (Math.sin(δ12) * Math.cos(φ2));
|
||||
var θa = Math.acos(Math.min(Math.max(cosθa, -1), 1)); // protect against rounding errors
|
||||
var θb = Math.acos(Math.min(Math.max(cosθb, -1), 1)); // protect against rounding errors
|
||||
var θ12 = Math.sin(λ2 - λ1) > 0 ? θa : 2 * π - θa;
|
||||
var θ21 = Math.sin(λ2 - λ1) > 0 ? 2 * π - θb : θb;
|
||||
var α1 = θ13 - θ12; // angle 2-1-3
|
||||
var α2 = θ21 - θ23; // angle 1-2-3
|
||||
if (Math.sin(α1) === 0 && Math.sin(α2) === 0) {
|
||||
return null; // infinite intersections
|
||||
}
|
||||
if (Math.sin(α1) * Math.sin(α2) < 0) {
|
||||
return null; // ambiguous intersection (antipodal?)
|
||||
}
|
||||
var cosα3 = -Math.cos(α1) * Math.cos(α2) + Math.sin(α1) * Math.sin(α2) * Math.cos(δ12);
|
||||
var δ13 = Math.atan2(Math.sin(δ12) * Math.sin(α1) * Math.sin(α2), Math.cos(α2) + Math.cos(α1) * cosα3);
|
||||
var φ3 = Math.asin(Math.min(Math.max(Math.sin(φ1) * Math.cos(δ13) + Math.cos(φ1) * Math.sin(δ13) * Math.cos(θ13), -1), 1));
|
||||
var Δλ13 = Math.atan2(Math.sin(θ13) * Math.sin(δ13) * Math.cos(φ1), Math.cos(δ13) - Math.sin(φ1) * Math.sin(φ3));
|
||||
var λ3 = λ1 + Δλ13;
|
||||
return new L__namespace.LatLng(this.toDegrees(φ3), this.toDegrees(λ3));
|
||||
};
|
||||
GeodesicCore.prototype.midpoint = function (start, dest) {
|
||||
// φm = atan2( sinφ1 + sinφ2, √( (cosφ1 + cosφ2⋅cosΔλ)² + cos²φ2⋅sin²Δλ ) )
|
||||
// λm = λ1 + atan2(cosφ2⋅sinΔλ, cosφ1 + cosφ2⋅cosΔλ)
|
||||
// midpoint is sum of vectors to two points: mathforum.org/library/drmath/view/51822.html
|
||||
var φ1 = this.toRadians(start.lat);
|
||||
var λ1 = this.toRadians(start.lng);
|
||||
var φ2 = this.toRadians(dest.lat);
|
||||
var Δλ = this.toRadians(dest.lng - start.lng);
|
||||
// get cartesian coordinates for the two points
|
||||
var A = { x: Math.cos(φ1), y: 0, z: Math.sin(φ1) }; // place point A on prime meridian y=0
|
||||
var B = { x: Math.cos(φ2) * Math.cos(Δλ), y: Math.cos(φ2) * Math.sin(Δλ), z: Math.sin(φ2) };
|
||||
// vector to midpoint is sum of vectors to two points (no need to normalise)
|
||||
var C = { x: A.x + B.x, y: A.y + B.y, z: A.z + B.z };
|
||||
var φm = Math.atan2(C.z, Math.sqrt(C.x * C.x + C.y * C.y));
|
||||
var λm = λ1 + Math.atan2(C.y, C.x);
|
||||
return new L__namespace.LatLng(this.toDegrees(φm), this.toDegrees(λm));
|
||||
};
|
||||
return GeodesicCore;
|
||||
}());
|
||||
|
||||
var GeodesicGeometry = /** @class */ (function () {
|
||||
function GeodesicGeometry(options) {
|
||||
var _a;
|
||||
this.geodesic = new GeodesicCore();
|
||||
this.steps = (_a = options === null || options === void 0 ? void 0 : options.steps) !== null && _a !== void 0 ? _a : 3;
|
||||
}
|
||||
/**
|
||||
* A geodesic line between `start` and `dest` is created with this recursive function.
|
||||
* It calculates the geodesic midpoint between `start` and `dest` and uses this midpoint to call itself again (twice!).
|
||||
* The results are then merged into one continuous linestring.
|
||||
*
|
||||
* The number of resulting vertices (incl. `start` and `dest`) depends on the initial value for `iterations`
|
||||
* and can be calculated with: vertices == 1 + 2 ** (initialIterations + 1)
|
||||
*
|
||||
* As this is an exponential function, be extra careful to limit the initial value for `iterations` (8 results in 513 vertices).
|
||||
*
|
||||
* @param start start position
|
||||
* @param dest destination
|
||||
* @param iterations
|
||||
* @return resulting linestring
|
||||
*/
|
||||
GeodesicGeometry.prototype.recursiveMidpoint = function (start, dest, iterations) {
|
||||
var geom = [start, dest];
|
||||
var midpoint = this.geodesic.midpoint(start, dest);
|
||||
if (iterations > 0) {
|
||||
geom.splice.apply(geom, __spreadArray([0, 1], this.recursiveMidpoint(start, midpoint, iterations - 1), false));
|
||||
geom.splice.apply(geom, __spreadArray([geom.length - 2, 2], this.recursiveMidpoint(midpoint, dest, iterations - 1), false));
|
||||
}
|
||||
else {
|
||||
geom.splice(1, 0, midpoint);
|
||||
}
|
||||
return geom;
|
||||
};
|
||||
/**
|
||||
* This is the wrapper-function to generate a geodesic line. It's just for future backwards-compatibility
|
||||
* if there is another algorithm used to create the actual line.
|
||||
*
|
||||
* The `steps`-property is used to define the number of resulting vertices of the linestring: vertices == 1 + 2 ** (steps + 1)
|
||||
* The value for `steps` is currently limited to 8 (513 vertices) for performance reasons until another algorithm is found.
|
||||
*
|
||||
* @param start start position
|
||||
* @param dest destination
|
||||
* @return resulting linestring
|
||||
*/
|
||||
GeodesicGeometry.prototype.line = function (start, dest) {
|
||||
return this.recursiveMidpoint(start, dest, Math.min(8, this.steps));
|
||||
};
|
||||
GeodesicGeometry.prototype.multiLineString = function (latlngs) {
|
||||
var multiLineString = [];
|
||||
for (var _i = 0, latlngs_1 = latlngs; _i < latlngs_1.length; _i++) {
|
||||
var linestring = latlngs_1[_i];
|
||||
var segment = [];
|
||||
for (var j = 1; j < linestring.length; j++) {
|
||||
segment.splice.apply(segment, __spreadArray([segment.length - 1, 1], this.line(linestring[j - 1], linestring[j]), false));
|
||||
}
|
||||
multiLineString.push(segment);
|
||||
}
|
||||
return multiLineString;
|
||||
};
|
||||
GeodesicGeometry.prototype.lineString = function (latlngs) {
|
||||
return this.multiLineString([latlngs])[0];
|
||||
};
|
||||
/**
|
||||
*
|
||||
* Is much (10x) faster than the previous implementation:
|
||||
*
|
||||
* ```
|
||||
* Benchmark (no split): splitLine x 459,044 ops/sec ±0.53% (95 runs sampled)
|
||||
* Benchmark (split): splitLine x 42,999 ops/sec ±0.51% (97 runs sampled)
|
||||
* ```
|
||||
*
|
||||
* @param startPosition
|
||||
* @param destPosition
|
||||
*/
|
||||
GeodesicGeometry.prototype.splitLine = function (startPosition, destPosition) {
|
||||
var antimeridianWest = {
|
||||
point: new L__namespace.LatLng(89.9, -180.0000001),
|
||||
bearing: 180
|
||||
};
|
||||
var antimeridianEast = {
|
||||
point: new L__namespace.LatLng(89.9, 180.0000001),
|
||||
bearing: 180
|
||||
};
|
||||
// make a copy to work with
|
||||
var start = new L__namespace.LatLng(startPosition.lat, startPosition.lng, startPosition.alt);
|
||||
var dest = new L__namespace.LatLng(destPosition.lat, destPosition.lng, destPosition.alt);
|
||||
start.lng = this.geodesic.wrap(start.lng, 360);
|
||||
dest.lng = this.geodesic.wrap(dest.lng, 360);
|
||||
if (dest.lng - start.lng > 180) {
|
||||
dest.lng = dest.lng - 360;
|
||||
}
|
||||
else if (dest.lng - start.lng < -180) {
|
||||
dest.lng = dest.lng + 360;
|
||||
}
|
||||
var result = [
|
||||
[
|
||||
new L__namespace.LatLng(start.lat, this.geodesic.wrap(start.lng, 180), start.alt),
|
||||
new L__namespace.LatLng(dest.lat, this.geodesic.wrap(dest.lng, 180), dest.alt)
|
||||
]
|
||||
];
|
||||
// crossing antimeridian from "this" side?
|
||||
if (start.lng >= -180 && start.lng <= 180) {
|
||||
// crossing the "western" antimeridian
|
||||
if (dest.lng < -180) {
|
||||
var bearing = this.geodesic.inverse(start, dest).initialBearing;
|
||||
var intersection = this.geodesic.intersection(start, bearing, antimeridianWest.point, antimeridianWest.bearing);
|
||||
if (intersection) {
|
||||
result = [
|
||||
[start, intersection],
|
||||
[
|
||||
new L__namespace.LatLng(intersection.lat, intersection.lng + 360),
|
||||
new L__namespace.LatLng(dest.lat, dest.lng + 360, dest.alt)
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
// crossing the "eastern" antimeridian
|
||||
else if (dest.lng > 180) {
|
||||
var bearing = this.geodesic.inverse(start, dest).initialBearing;
|
||||
var intersection = this.geodesic.intersection(start, bearing, antimeridianEast.point, antimeridianEast.bearing);
|
||||
if (intersection) {
|
||||
result = [
|
||||
[start, intersection],
|
||||
[
|
||||
new L__namespace.LatLng(intersection.lat, intersection.lng - 360),
|
||||
new L__namespace.LatLng(dest.lat, dest.lng - 360, dest.alt)
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
// coming back over the antimeridian from the "other" side?
|
||||
else if (dest.lng >= -180 && dest.lng <= 180) {
|
||||
// crossing the "western" antimeridian
|
||||
if (start.lng < -180) {
|
||||
var bearing = this.geodesic.inverse(start, dest).initialBearing;
|
||||
var intersection = this.geodesic.intersection(start, bearing, antimeridianWest.point, antimeridianWest.bearing);
|
||||
if (intersection) {
|
||||
result = [
|
||||
[
|
||||
new L__namespace.LatLng(start.lat, start.lng + 360, start.alt),
|
||||
new L__namespace.LatLng(intersection.lat, intersection.lng + 360)
|
||||
],
|
||||
[intersection, dest]
|
||||
];
|
||||
}
|
||||
}
|
||||
// crossing the "eastern" antimeridian
|
||||
else if (start.lng > 180) {
|
||||
var bearing = this.geodesic.inverse(start, dest).initialBearing;
|
||||
var intersection = this.geodesic.intersection(start, bearing, antimeridianWest.point, antimeridianWest.bearing);
|
||||
if (intersection) {
|
||||
result = [
|
||||
[
|
||||
new L__namespace.LatLng(start.lat, start.lng - 360, start.alt),
|
||||
new L__namespace.LatLng(intersection.lat, intersection.lng - 360)
|
||||
],
|
||||
[intersection, dest]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Linestrings of a given multilinestring that cross the antimeridian will be split in two separate linestrings.
|
||||
* This function is used to wrap lines around when they cross the antimeridian
|
||||
* It iterates over all linestrings and reconstructs the step-by-step if no split is needed.
|
||||
* In case the line was split, the linestring ends at the antimeridian and a new linestring is created for the
|
||||
* remaining points of the original linestring.
|
||||
*
|
||||
* @param multilinestring
|
||||
* @return another multilinestring where segments crossing the antimeridian are split
|
||||
*/
|
||||
GeodesicGeometry.prototype.splitMultiLineString = function (multilinestring) {
|
||||
var result = [];
|
||||
for (var _i = 0, multilinestring_1 = multilinestring; _i < multilinestring_1.length; _i++) {
|
||||
var linestring = multilinestring_1[_i];
|
||||
if (linestring.length === 1) {
|
||||
result.push(linestring); // just a single point in linestring, no need to split
|
||||
continue;
|
||||
}
|
||||
var segment = [];
|
||||
for (var j = 1; j < linestring.length; j++) {
|
||||
var split = this.splitLine(linestring[j - 1], linestring[j]);
|
||||
segment.pop();
|
||||
segment = segment.concat(split[0]);
|
||||
if (split.length > 1) {
|
||||
result.push(segment); // the line was split, so we end the linestring right here
|
||||
segment = split[1]; // begin the new linestring with the second part of the split line
|
||||
}
|
||||
}
|
||||
result.push(segment);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Linestrings of a given multilinestring will be wrapped (+- 360°) to show a continuous line w/o any weird discontinuities
|
||||
* when `wrap` is set to `false` in the geodesic class
|
||||
* @param multilinestring
|
||||
* @returns another multilinestring where the points of each linestring are wrapped accordingly
|
||||
*/
|
||||
GeodesicGeometry.prototype.wrapMultiLineString = function (multilinestring) {
|
||||
var result = [];
|
||||
for (var _i = 0, multilinestring_2 = multilinestring; _i < multilinestring_2.length; _i++) {
|
||||
var linestring = multilinestring_2[_i];
|
||||
var resultLine = [];
|
||||
var previous = null;
|
||||
// iterate over every point and check if it needs to be wrapped
|
||||
for (var _a = 0, linestring_1 = linestring; _a < linestring_1.length; _a++) {
|
||||
var point = linestring_1[_a];
|
||||
if (previous === null) {
|
||||
// the first point is the anchor of the linestring from which the line will always start (w/o any wrapping applied)
|
||||
resultLine.push(new L__namespace.LatLng(point.lat, point.lng));
|
||||
previous = new L__namespace.LatLng(point.lat, point.lng);
|
||||
}
|
||||
else {
|
||||
// I prefer clearly defined branches over a continue-operation.
|
||||
// if the difference between the current and *previous* point is greater than 360°, the current point needs to be shifted
|
||||
// to be on the same 'sphere' as the previous one.
|
||||
var offset = Math.round((point.lng - previous.lng) / 360);
|
||||
// shift the point accordingly and add to the result
|
||||
resultLine.push(new L__namespace.LatLng(point.lat, point.lng - offset * 360));
|
||||
// use the wrapped point as the anchor for the next one
|
||||
previous = new L__namespace.LatLng(point.lat, point.lng - offset * 360); // Need a new object here, to avoid changing the input data
|
||||
}
|
||||
}
|
||||
result.push(resultLine);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Creates a circular (constant radius), closed (1st pos == last pos) geodesic linestring.
|
||||
* The number of vertices is calculated with: `vertices == steps + 1` (where 1st == last)
|
||||
*
|
||||
* @param center
|
||||
* @param radius
|
||||
* @return resulting linestring
|
||||
*/
|
||||
GeodesicGeometry.prototype.circle = function (center, radius) {
|
||||
var vertices = [];
|
||||
for (var i = 0; i < this.steps; i++) {
|
||||
var point = this.geodesic.direct(center, (360 / this.steps) * i, radius);
|
||||
vertices.push(new L__namespace.LatLng(point.lat, point.lng));
|
||||
}
|
||||
// append first vertice to the end to close the linestring
|
||||
vertices.push(new L__namespace.LatLng(vertices[0].lat, vertices[0].lng));
|
||||
return vertices;
|
||||
};
|
||||
/**
|
||||
* Handles splitting of circles at the antimeridian.
|
||||
* @param linestring a linestring that resembles the geodesic circle
|
||||
* @return a multilinestring that consist of one or two linestrings
|
||||
*/
|
||||
GeodesicGeometry.prototype.splitCircle = function (linestring) {
|
||||
var result = this.splitMultiLineString([linestring]);
|
||||
// If the circle was split, it results in exactly three linestrings where first and last
|
||||
// must be re-assembled because they belong to the same "side" of the split circle.
|
||||
if (result.length === 3) {
|
||||
result[2] = __spreadArray(__spreadArray([], result[2], true), result[0], true);
|
||||
result.shift();
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Calculates the distance between two positions on the earths surface
|
||||
* @param start 1st position
|
||||
* @param dest 2nd position
|
||||
* @return the distance in **meters**
|
||||
*/
|
||||
GeodesicGeometry.prototype.distance = function (start, dest) {
|
||||
return this.geodesic.inverse(new L__namespace.LatLng(start.lat, this.geodesic.wrap(start.lng, 180)), new L__namespace.LatLng(dest.lat, this.geodesic.wrap(dest.lng, 180))).distance;
|
||||
};
|
||||
GeodesicGeometry.prototype.multilineDistance = function (multilinestring) {
|
||||
var dist = [];
|
||||
for (var _i = 0, multilinestring_3 = multilinestring; _i < multilinestring_3.length; _i++) {
|
||||
var linestring = multilinestring_3[_i];
|
||||
var segmentDistance = 0;
|
||||
for (var j = 1; j < linestring.length; j++) {
|
||||
segmentDistance += this.distance(linestring[j - 1], linestring[j]);
|
||||
}
|
||||
dist.push(segmentDistance);
|
||||
}
|
||||
return dist;
|
||||
};
|
||||
GeodesicGeometry.prototype.updateStatistics = function (points, vertices) {
|
||||
var stats = { distanceArray: [], totalDistance: 0, points: 0, vertices: 0 };
|
||||
stats.distanceArray = this.multilineDistance(points);
|
||||
stats.totalDistance = stats.distanceArray.reduce(function (x, y) { return x + y; }, 0);
|
||||
stats.points = 0;
|
||||
for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
|
||||
var item = points_1[_i];
|
||||
stats.points += item.reduce(function (x) { return x + 1; }, 0);
|
||||
}
|
||||
stats.vertices = 0;
|
||||
for (var _a = 0, vertices_1 = vertices; _a < vertices_1.length; _a++) {
|
||||
var item = vertices_1[_a];
|
||||
stats.vertices += item.reduce(function (x) { return x + 1; }, 0);
|
||||
}
|
||||
return stats;
|
||||
};
|
||||
return GeodesicGeometry;
|
||||
}());
|
||||
|
||||
function instanceOfLatLngLiteral(object) {
|
||||
return ((typeof object === "object")
|
||||
&& (object !== null)
|
||||
&& ("lat" in object)
|
||||
&& ("lng" in object)
|
||||
&& (typeof object.lat === "number")
|
||||
&& (typeof object.lng === "number"));
|
||||
}
|
||||
function instanceOfLatLngTuple(object) {
|
||||
return ((object instanceof Array)
|
||||
&& (typeof object[0] === "number")
|
||||
&& (typeof object[1] === "number"));
|
||||
}
|
||||
function instanceOfLatLngExpression(object) {
|
||||
return object instanceof L__namespace.LatLng || instanceOfLatLngTuple(object) || instanceOfLatLngLiteral(object);
|
||||
}
|
||||
function latlngExpressiontoLatLng(input) {
|
||||
if (input instanceof L__namespace.LatLng) {
|
||||
return input;
|
||||
}
|
||||
else if (instanceOfLatLngTuple(input)) {
|
||||
return new L__namespace.LatLng(input[0], input[1], input.at(2)); // alt is optional
|
||||
}
|
||||
else if (instanceOfLatLngLiteral(input)) {
|
||||
return new L__namespace.LatLng(input.lat, input.lng, input.alt);
|
||||
}
|
||||
throw new Error("L.LatLngExpression expected. Unknown object found.");
|
||||
}
|
||||
function latlngExpressionArraytoLatLngArray(input) {
|
||||
var latlng = [];
|
||||
var iterateOver = instanceOfLatLngExpression(input[0]) ? [input] : input;
|
||||
var unknownObjectError = new Error("L.LatLngExpression[] | L.LatLngExpression[][] expected. Unknown object found.");
|
||||
if (!(iterateOver instanceof Array)) {
|
||||
throw unknownObjectError;
|
||||
}
|
||||
for (var _i = 0, _a = iterateOver; _i < _a.length; _i++) {
|
||||
var group = _a[_i];
|
||||
if (!(group instanceof Array)) {
|
||||
throw unknownObjectError;
|
||||
}
|
||||
var sub = [];
|
||||
for (var _b = 0, group_1 = group; _b < group_1.length; _b++) {
|
||||
var point = group_1[_b];
|
||||
if (!instanceOfLatLngExpression(point)) {
|
||||
throw unknownObjectError;
|
||||
}
|
||||
sub.push(latlngExpressiontoLatLng(point));
|
||||
}
|
||||
latlng.push(sub);
|
||||
}
|
||||
return latlng;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw geodesic lines based on L.Polyline
|
||||
*/
|
||||
var GeodesicLine = /** @class */ (function (_super) {
|
||||
__extends(GeodesicLine, _super);
|
||||
function GeodesicLine(latlngs, options) {
|
||||
var _this = _super.call(this, [], options) || this;
|
||||
/** these should be good for most use-cases */
|
||||
_this.defaultOptions = { wrap: true, steps: 3 };
|
||||
/** use this if you need some detailled info about the current geometry */
|
||||
_this.statistics = { distanceArray: [], totalDistance: 0, points: 0, vertices: 0 };
|
||||
/** stores all positions that are used to create the geodesic line */
|
||||
_this.points = [];
|
||||
L__namespace.Util.setOptions(_this, __assign(__assign({}, _this.defaultOptions), options));
|
||||
_this.geom = new GeodesicGeometry(_this.options);
|
||||
if (latlngs !== undefined) {
|
||||
_this.setLatLngs(latlngs);
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
/** calculates the geodesics and update the polyline-object accordingly */
|
||||
GeodesicLine.prototype.updateGeometry = function () {
|
||||
var geodesic = [];
|
||||
geodesic = this.geom.multiLineString(this.points);
|
||||
this.statistics = this.geom.updateStatistics(this.points, geodesic);
|
||||
if (this.options.wrap) {
|
||||
var split = this.geom.splitMultiLineString(geodesic);
|
||||
_super.prototype.setLatLngs.call(this, split);
|
||||
}
|
||||
else {
|
||||
_super.prototype.setLatLngs.call(this, this.geom.wrapMultiLineString(geodesic));
|
||||
}
|
||||
};
|
||||
/**
|
||||
* overwrites the original function with additional functionality to create a geodesic line
|
||||
* @param latlngs an array (or 2d-array) of positions
|
||||
*/
|
||||
GeodesicLine.prototype.setLatLngs = function (latlngs) {
|
||||
this.points = latlngExpressionArraytoLatLngArray(latlngs);
|
||||
this.updateGeometry();
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* add a given point to the geodesic line object
|
||||
* @param latlng point to add. The point will always be added to the last linestring of a multiline
|
||||
* @param latlngs define a linestring to add the new point to. Read from points-property before (e.g. `line.addLatLng(Beijing, line.points[0]);`)
|
||||
*/
|
||||
GeodesicLine.prototype.addLatLng = function (latlng, latlngs) {
|
||||
var point = latlngExpressiontoLatLng(latlng);
|
||||
if (this.points.length === 0) {
|
||||
this.points.push([point]);
|
||||
}
|
||||
else if (latlngs === undefined) {
|
||||
this.points[this.points.length - 1].push(point);
|
||||
}
|
||||
else {
|
||||
latlngs.push(point);
|
||||
}
|
||||
this.updateGeometry();
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* Creates geodesic lines from a given GeoJSON-Object.
|
||||
* @param input GeoJSON-Object
|
||||
*/
|
||||
GeodesicLine.prototype.fromGeoJson = function (input) {
|
||||
var latlngs = [];
|
||||
var features = [];
|
||||
if (input.type === "FeatureCollection") {
|
||||
features = input.features;
|
||||
}
|
||||
else if (input.type === "Feature") {
|
||||
features = [input];
|
||||
}
|
||||
else if (["MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"].includes(input.type)) {
|
||||
features = [
|
||||
{
|
||||
type: "Feature",
|
||||
geometry: input,
|
||||
properties: {}
|
||||
}
|
||||
];
|
||||
}
|
||||
else {
|
||||
console.log("[Leaflet.Geodesic] fromGeoJson() - Type \"".concat(input.type, "\" not supported."));
|
||||
}
|
||||
features.forEach(function (feature) {
|
||||
switch (feature.geometry.type) {
|
||||
case "MultiPoint":
|
||||
case "LineString":
|
||||
latlngs = __spreadArray(__spreadArray([], latlngs, true), [L__namespace.GeoJSON.coordsToLatLngs(feature.geometry.coordinates, 0)], false);
|
||||
break;
|
||||
case "MultiLineString":
|
||||
case "Polygon":
|
||||
latlngs = __spreadArray(__spreadArray([], latlngs, true), L__namespace.GeoJSON.coordsToLatLngs(feature.geometry.coordinates, 1), true);
|
||||
break;
|
||||
case "MultiPolygon":
|
||||
feature.geometry.coordinates.forEach(function (item) {
|
||||
latlngs = __spreadArray(__spreadArray([], latlngs, true), L__namespace.GeoJSON.coordsToLatLngs(item, 1), true);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
console.log("[Leaflet.Geodesic] fromGeoJson() - Type \"".concat(feature.geometry.type, "\" not supported."));
|
||||
}
|
||||
});
|
||||
if (latlngs.length) {
|
||||
this.setLatLngs(latlngs);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* Calculates the distance between two geo-positions
|
||||
* @param start 1st position
|
||||
* @param dest 2nd position
|
||||
* @return the distance in meters
|
||||
*/
|
||||
GeodesicLine.prototype.distance = function (start, dest) {
|
||||
return this.geom.distance(latlngExpressiontoLatLng(start), latlngExpressiontoLatLng(dest));
|
||||
};
|
||||
return GeodesicLine;
|
||||
}(L__namespace.Polyline));
|
||||
|
||||
/**
|
||||
* Can be used to create a geodesic circle based on L.Polyline
|
||||
*/
|
||||
var GeodesicCircleClass = /** @class */ (function (_super) {
|
||||
__extends(GeodesicCircleClass, _super);
|
||||
function GeodesicCircleClass(center, options) {
|
||||
var _a;
|
||||
var _this = _super.call(this, [], options) || this;
|
||||
_this.defaultOptions = { wrap: true, steps: 24, fill: true, noClip: true };
|
||||
_this.statistics = { distanceArray: [], totalDistance: 0, points: 0, vertices: 0 };
|
||||
L__namespace.Util.setOptions(_this, __assign(__assign({}, _this.defaultOptions), options));
|
||||
// merge/set options
|
||||
var extendedOptions = _this.options;
|
||||
_this.radius = (_a = extendedOptions.radius) !== null && _a !== void 0 ? _a : 1000 * 1000;
|
||||
_this.center = center === undefined ? new L__namespace.LatLng(0, 0) : latlngExpressiontoLatLng(center);
|
||||
_this.geom = new GeodesicGeometry(_this.options);
|
||||
// update the geometry
|
||||
_this.update();
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Updates the geometry and re-calculates some statistics
|
||||
*/
|
||||
GeodesicCircleClass.prototype.update = function () {
|
||||
var circle = this.geom.circle(this.center, this.radius);
|
||||
this.statistics = this.geom.updateStatistics([[this.center]], [circle]);
|
||||
// circumfence must be re-calculated from geodesic
|
||||
this.statistics.totalDistance = this.geom.multilineDistance([circle]).reduce(function (x, y) { return x + y; }, 0);
|
||||
if (this.options.wrap) {
|
||||
var split = this.geom.splitCircle(circle);
|
||||
_super.prototype.setLatLngs.call(this, split);
|
||||
}
|
||||
else {
|
||||
_super.prototype.setLatLngs.call(this, circle);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Calculate the distance between the current center and an arbitrary position.
|
||||
* @param latlng geo-position to calculate distance to
|
||||
* @return distance in meters
|
||||
*/
|
||||
GeodesicCircleClass.prototype.distanceTo = function (latlng) {
|
||||
var dest = latlngExpressiontoLatLng(latlng);
|
||||
return this.geom.distance(this.center, dest);
|
||||
};
|
||||
/**
|
||||
* Set a new center for the geodesic circle and update the geometry. Radius may also be set.
|
||||
* @param center the new center
|
||||
* @param radius the new radius
|
||||
*/
|
||||
GeodesicCircleClass.prototype.setLatLng = function (center, radius) {
|
||||
this.center = latlngExpressiontoLatLng(center);
|
||||
this.radius = radius !== null && radius !== void 0 ? radius : this.radius;
|
||||
this.update();
|
||||
};
|
||||
/**
|
||||
* Set a new radius for the geodesic circle and update the geometry. Center may also be set.
|
||||
* @param radius the new radius
|
||||
* @param center the new center
|
||||
*/
|
||||
GeodesicCircleClass.prototype.setRadius = function (radius, center) {
|
||||
this.radius = radius;
|
||||
this.center = center ? latlngExpressiontoLatLng(center) : this.center;
|
||||
this.update();
|
||||
};
|
||||
return GeodesicCircleClass;
|
||||
}(L__namespace.Polyline));
|
||||
|
||||
if (typeof window.L !== "undefined") {
|
||||
window.L.Geodesic = GeodesicLine;
|
||||
window.L.geodesic = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return new (GeodesicLine.bind.apply(GeodesicLine, __spreadArray([void 0], args, false)))();
|
||||
};
|
||||
window.L.GeodesicCircle = GeodesicCircleClass;
|
||||
window.L.geodesiccircle = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return new (GeodesicCircleClass.bind.apply(GeodesicCircleClass, __spreadArray([void 0], args, false)))();
|
||||
};
|
||||
}
|
||||
|
||||
exports.GeodesicCircleClass = GeodesicCircleClass;
|
||||
exports.GeodesicLine = GeodesicLine;
|
||||
|
||||
}));
|
||||
4838
node_modules/leaflet.geodesic/dist/leaflet.geodesic.umd.js.stats.html
generated
vendored
Normal file
4838
node_modules/leaflet.geodesic/dist/leaflet.geodesic.umd.js.stats.html
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/leaflet.geodesic/dist/leaflet.geodesic.umd.min.js
generated
vendored
Normal file
2
node_modules/leaflet.geodesic/dist/leaflet.geodesic.umd.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/leaflet.geodesic/dist/leaflet.geodesic.umd.min.js.sha512
generated
vendored
Normal file
1
node_modules/leaflet.geodesic/dist/leaflet.geodesic.umd.min.js.sha512
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
iaFsrOsrVQKaxgOutC3x1hPWfg3K6DjcKZrxchqbO8amLrjJyYw7/ukh3ar4kly4kK2m5z5qiB3+Dt5RI5Pq4g==
|
||||
79
node_modules/leaflet.geodesic/package.json
generated
vendored
Normal file
79
node_modules/leaflet.geodesic/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
"name": "leaflet.geodesic",
|
||||
"version": "2.7.1",
|
||||
"description": "Add-on to draw geodesic lines with leaflet",
|
||||
"main": "dist/leaflet.geodesic.js",
|
||||
"module": "dist/leaflet.geodesic.esm.js",
|
||||
"browser": "dist/leaflet.geodesic.umd.min.js",
|
||||
"types": "dist/leaflet.geodesic.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/henrythasler/Leaflet.Geodesic.git"
|
||||
},
|
||||
"keywords": [
|
||||
"leaflet",
|
||||
"geodesic",
|
||||
"arc"
|
||||
],
|
||||
"author": "Henry Thasler",
|
||||
"license": "GPL-3.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/henrythasler/Leaflet.Geodesic/issues"
|
||||
},
|
||||
"homepage": "https://github.com/henrythasler/Leaflet.Geodesic#readme",
|
||||
"directories": {
|
||||
"example": "./docs",
|
||||
"test": "./spec"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"leaflet": "^1.9.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^25.0.4",
|
||||
"@rollup/plugin-node-resolve": "^15.2.1",
|
||||
"@rollup/plugin-terser": "^0.4.3",
|
||||
"@rollup/plugin-typescript": "^11.1.4",
|
||||
"@types/benchmark": "^2.1.3",
|
||||
"@types/chai": "^4.3.6",
|
||||
"@types/geojson": "^7946.0.11",
|
||||
"@types/jest": "^29.5.5",
|
||||
"@types/leaflet": "^1.9.6",
|
||||
"@types/node": "^20.7.2",
|
||||
"@typescript-eslint/eslint-plugin": "^6.7.3",
|
||||
"@typescript-eslint/parser": "^6.7.3",
|
||||
"benchmark": "^2.1.4",
|
||||
"chai": "^4.3.10",
|
||||
"coveralls": "^3.1.1",
|
||||
"eslint": "^8.50.0",
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"leaflet": "^1.9.4",
|
||||
"prettier": "^3.0.3",
|
||||
"rollup": "^3.29.4",
|
||||
"rollup-plugin-dts": "^6.0.2",
|
||||
"rollup-plugin-visualizer": "^5.9.2",
|
||||
"ts-jest": "^29.1.1",
|
||||
"tslib": "^2.6.2",
|
||||
"typedoc": "^0.25.1",
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest \"^(?!.*benchmark).*$\" --coverage --",
|
||||
"test:solo": "jest --coverage --",
|
||||
"benchmark": "jest benchmark",
|
||||
"linter": "eslint src/**/*.ts",
|
||||
"prettier": "prettier --config .prettierrc 'src/**/*.ts' --write",
|
||||
"docs": "typedoc",
|
||||
"build:tools": "tsc tools/prebuild.ts && tsc tools/postbuild.ts",
|
||||
"prebuild": "node tools/prebuild.js",
|
||||
"build": "rollup --config rollup.config.prod.ts --configPlugin typescript",
|
||||
"build:dev": "npm run prebuild && rollup --config rollup.config.dev.ts --configPlugin typescript && npm run postbuild",
|
||||
"postbuild": "node tools/postbuild.js"
|
||||
},
|
||||
"np": {
|
||||
"publish": false
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue