Compare commits
No commits in common. "master" and "solid" have entirely different histories.
|
@ -3,4 +3,3 @@ dist/
|
||||||
android/
|
android/
|
||||||
ios/
|
ios/
|
||||||
vite.config.ts.timestamp-*.mjs
|
vite.config.ts.timestamp-*.mjs
|
||||||
$*$/
|
|
|
@ -1,8 +1,5 @@
|
||||||
{
|
{
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"esbenp.prettier-vscode",
|
"ionic.ionic"
|
||||||
"streetsidesoftware.code-spell-checker",
|
]
|
||||||
"streetsidesoftware.code-spell-checker-french",
|
|
||||||
"solidjs-community.solid-snippets"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,5 @@
|
||||||
"docuri",
|
"docuri",
|
||||||
"Dyomedea",
|
"Dyomedea",
|
||||||
"stackoverflow"
|
"stackoverflow"
|
||||||
],
|
]
|
||||||
"workbench.colorTheme": "Default Light Modern"
|
|
||||||
}
|
}
|
|
@ -34,9 +34,7 @@
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
|
||||||
<data android:scheme="geo" />
|
<data android:scheme="geo" />
|
||||||
<data android:scheme="" />
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -45,71 +43,19 @@
|
||||||
<data android:mimeType="application/gpx+xml" />
|
<data android:mimeType="application/gpx+xml" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="application/gpx+xml" />
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.SEND" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="application/xml" />
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="application/xml" />
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND" />
|
<action android:name="android.intent.action.SEND" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<data android:mimeType="text/xml" />
|
<data android:mimeType="text/xml" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="text/xml" />
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.SEND" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="text/plain" />
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.SEND" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="image/*" />
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.SEND" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="file/*" />
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action
|
<action
|
||||||
android:name="com.darryncampbell.cordova.plugin.intent.ACTION"
|
android:name="com.darryncampbell.cordova.plugin.intent.ACTION"
|
||||||
/>
|
/>
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<intent-filter android:autoVerify="true">
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
|
||||||
<data android:scheme="https" />
|
|
||||||
<data android:host="web.dyomedea.app" />
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
|
@ -146,7 +92,4 @@
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
675
LICENSE.md
|
@ -1,675 +0,0 @@
|
||||||
### GNU GENERAL PUBLIC LICENSE
|
|
||||||
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
|
||||||
<https://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 <https://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:
|
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
|
||||||
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 <https://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 <https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
18
README.md
|
@ -1,16 +1,5 @@
|
||||||
# Dyomedea
|
# Dyomedea
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
GPL 3.0.
|
|
||||||
|
|
||||||
## Branches
|
|
||||||
|
|
||||||
* master: dev (and only active) branch (started as a React project, now using solidjs)
|
|
||||||
* multi-layers: (deprecated) attempt to create a native React map components. Went pretty far but there was still so many things to implement that I switched to:
|
|
||||||
* openlayers: (deprecated) an attempt to use React with Openlayers. Wasn't that easy because Openlayers is heavily based on the DOM while React uses a "pseudo-dom". That has been one of the reasons why I switched (again) to:
|
|
||||||
* solid: (merged into master and deprecated) a SolidJS / Openlayers implementation that has replaced the master branch on Feb 5th, 2023.
|
|
||||||
|
|
||||||
## Hiking app.
|
## Hiking app.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
@ -113,7 +102,7 @@ $ npx cap run --target RFCN20NEZ4R android
|
||||||
vdv@nuc:~/projects/tea/dyomedea/dyomedea$ esrun helper.ts
|
vdv@nuc:~/projects/tea/dyomedea/dyomedea$ esrun helper.ts
|
||||||
{
|
{
|
||||||
caller: 'overlay-definitions',
|
caller: 'overlay-definitions',
|
||||||
legacyOverlayDefinitions: {
|
overlayDefinitions: {
|
||||||
amenity: {
|
amenity: {
|
||||||
bar: [Object],
|
bar: [Object],
|
||||||
fast_food: [Object],
|
fast_food: [Object],
|
||||||
|
@ -224,7 +213,7 @@ vdv@nuc:~/projects/tea/dyomedea/dyomedea$ esrun helper.ts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
legacyOverlayDefinitions: {
|
overlayDefinitions: {
|
||||||
amenity: {
|
amenity: {
|
||||||
bar: [Object],
|
bar: [Object],
|
||||||
fast_food: [Object],
|
fast_food: [Object],
|
||||||
|
@ -354,9 +343,6 @@ Requires esrun (`sudo npm i -g @digitak/esrun`)
|
||||||
|
|
||||||
### Patches
|
### Patches
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* suid: https://github.com/swordev/suid/issues/89
|
* suid: https://github.com/swordev/suid/issues/89
|
||||||
|
|
||||||
### NPM updates: use npm-check-updates !
|
### NPM updates: use npm-check-updates !
|
||||||
|
|
|
@ -4,9 +4,7 @@ const config: CapacitorConfig = {
|
||||||
appId: 'com.dyomedea.dyomedea',
|
appId: 'com.dyomedea.dyomedea',
|
||||||
appName: 'dyomedea',
|
appName: 'dyomedea',
|
||||||
webDir: 'dist',
|
webDir: 'dist',
|
||||||
server: {
|
bundledWebRuntime: false
|
||||||
androidScheme: 'https'
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
const typesPath = path.resolve('node_modules', '@types', 'testing-library__jest-dom', 'index.d.ts');
|
||||||
|
|
||||||
|
fs.readFile(typesPath, 'utf8', (err, data) => {
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
|
let lines = data.split('\n');
|
||||||
|
|
||||||
|
if (lines[8] === '/// <reference types="jest" />') {
|
||||||
|
lines = lines.slice(0, 8).concat(lines.slice(9));
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFile(typesPath, lines.join('\n'), 'utf8', function(err) {
|
||||||
|
if (err) throw err;
|
||||||
|
});
|
||||||
|
});
|
71
helper.ts
|
@ -1,63 +1,14 @@
|
||||||
import {
|
import { overlayDefinitions } from './src/components/overlays/overlay-definitions';
|
||||||
overlayDefinitions,
|
|
||||||
osmTags,
|
|
||||||
} from './src/components/overlays/overlay-definitions';
|
|
||||||
|
|
||||||
// One timer
|
let filters: any[] = ['any'];
|
||||||
|
|
||||||
// let tags = {};
|
Object.keys(overlayDefinitions).forEach((key) => {
|
||||||
// let overlays = {};
|
const definition = overlayDefinitions[key];
|
||||||
|
let filter: any[] = ['in', key];
|
||||||
|
Object.keys(definition).forEach((subKey) => {
|
||||||
|
filter = [...filter, subKey];
|
||||||
|
});
|
||||||
|
filters = [...filters, filter];
|
||||||
|
});
|
||||||
|
|
||||||
// for (const tagName of Object.keys(legacyOverlayDefinitions)) {
|
console.log({ overlayDefinitions, filters, json: JSON.stringify(filters) });
|
||||||
// for (const tagValue of Object.keys(legacyOverlayDefinitions[tagName])) {
|
|
||||||
// tags[tagValue] = { name: tagName, value: tagValue };
|
|
||||||
// for (const activity of Object.keys(
|
|
||||||
// legacyOverlayDefinitions[tagName][tagValue]
|
|
||||||
// )) {
|
|
||||||
// if (!overlays[activity]) {
|
|
||||||
// overlays[activity] = {};
|
|
||||||
// }
|
|
||||||
// for (const category of Object.keys(
|
|
||||||
// legacyOverlayDefinitions[tagName][tagValue][activity]
|
|
||||||
// )) {
|
|
||||||
// if (!overlays[activity][category]) {
|
|
||||||
// overlays[activity][category] = [];
|
|
||||||
// }
|
|
||||||
// overlays[activity][category].push(tagValue);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// console.log({
|
|
||||||
// caller: 'onetimer / result',
|
|
||||||
// tags: JSON.stringify(tags),
|
|
||||||
// overlays: JSON.stringify(overlays),
|
|
||||||
// });
|
|
||||||
|
|
||||||
// End of one timer
|
|
||||||
|
|
||||||
for (const overlayCategory of Object.keys(overlayDefinitions)) {
|
|
||||||
let filters: any[] = ['any'];
|
|
||||||
const definitions = overlayDefinitions[overlayCategory];
|
|
||||||
let tags = {};
|
|
||||||
for (const category of Object.keys(definitions)) {
|
|
||||||
//console.log({ category });
|
|
||||||
for (const tagId of definitions[category]) {
|
|
||||||
//console.log({ tagId });
|
|
||||||
const tag = osmTags[tagId];
|
|
||||||
if (!tags[tag.name]) {
|
|
||||||
tags[tag.name] = [];
|
|
||||||
}
|
|
||||||
tags[tag.name].push(tag.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const tagName of Object.keys(tags)) {
|
|
||||||
let filter = ['in', tagName];
|
|
||||||
for (const tagValue of tags[tagName]) {
|
|
||||||
filter.push(tagValue);
|
|
||||||
}
|
|
||||||
filters.push(filter);
|
|
||||||
}
|
|
||||||
console.log({ overlayCategory, filters: JSON.stringify(filters) });
|
|
||||||
}
|
|
||||||
|
|
79
package.json
|
@ -7,64 +7,53 @@
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"serve": "vite preview --host",
|
"serve": "vite preview",
|
||||||
"test": "vitest",
|
"test": "vitest",
|
||||||
"postinstall": "patch-package"
|
"postinstall": "node ./fix-jest-dom.mjs"
|
||||||
},
|
},
|
||||||
"license": "GPL-3.0-only",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@capacitor/cli": "^5.4.2",
|
"@capacitor/cli": "^4.6.3",
|
||||||
"@solidjs/testing-library": "^0.8.4",
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
"@testing-library/jest-dom": "^6.1.3",
|
"@types/lodash": "^4.14.191",
|
||||||
"@types/lodash": "^4.14.199",
|
"@types/memoizee": "^0.4.8",
|
||||||
"@types/memoizee": "^0.4.9",
|
|
||||||
"@types/pouchdb": "^6.4.0",
|
"@types/pouchdb": "^6.4.0",
|
||||||
"@types/proj4": "^2.5.3",
|
"@types/proj4": "^2.5.2",
|
||||||
"@types/shelljs": "^0.8.13",
|
"jsdom": ">=21.1.0",
|
||||||
"@vitest/ui": "^0.34.6",
|
"solid-testing-library": ">=0.5.0",
|
||||||
"jsdom": "^22.1.0",
|
"typescript": "^4.9.5",
|
||||||
"license-checker": "^25.0.1",
|
"vite": ">=4.1.1",
|
||||||
"license-compatibility-checker": "^0.3.5",
|
"vite-plugin-solid": "^2.5.0",
|
||||||
"license-report": "^6.4.0",
|
"vitest": ">=0.28.4"
|
||||||
"shelljs": "^0.8.5",
|
|
||||||
"typescript": "^5.2.2",
|
|
||||||
"vite": ">=4.4.11",
|
|
||||||
"vite-plugin-solid": "^2.7.0",
|
|
||||||
"vitest": "^0.34.6"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@awesome-cordova-plugins/android-full-screen": "^6.4.0",
|
"@awesome-cordova-plugins/android-full-screen": "^6.3.0",
|
||||||
"@awesome-cordova-plugins/geolocation": "^6.4.0",
|
"@awesome-cordova-plugins/geolocation": "^6.3.0",
|
||||||
"@awesome-cordova-plugins/web-intent": "^6.4.0",
|
"@awesome-cordova-plugins/web-intent": "^6.3.0",
|
||||||
"@capacitor-community/background-geolocation": "^1.2.15",
|
"@capacitor-community/background-geolocation": "^1.2.7",
|
||||||
"@capacitor/android": "^5.4.2",
|
"@capacitor/android": "^4.6.3",
|
||||||
"@capacitor/browser": "^5.1.0",
|
"@capacitor/browser": "^4.1.1",
|
||||||
"@capacitor/core": "^5.4.2",
|
"@capacitor/core": "^4.6.3",
|
||||||
"@capacitor/filesystem": "^5.1.4",
|
"@capacitor/filesystem": "^4.1.4",
|
||||||
"@capacitor/ios": "^5.4.2",
|
"@capacitor/ios": "^4.6.3",
|
||||||
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
||||||
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
||||||
"@solid-primitives/i18n": "^2.0.0",
|
"@solid-primitives/i18n": "^1.1.3",
|
||||||
"@solidjs/router": "^0.8.3",
|
"@solidjs/router": "^0.7.0",
|
||||||
"@suid/icons-material": "^0.6.11",
|
"@suid/icons-material": "^0.5.8",
|
||||||
"@suid/material": "^0.15.1",
|
"@suid/material": "^0.10.1",
|
||||||
"@suid/vite-plugin": "^0.1.5",
|
"@suid/vite-plugin": "^0.1.2",
|
||||||
"blob-util": "^2.0.2",
|
|
||||||
"com-darryncampbell-cordova-plugin-intent": "^2.2.0",
|
"com-darryncampbell-cordova-plugin-intent": "^2.2.0",
|
||||||
"cordova-plugin-fullscreen": "^1.3.0",
|
"cordova-plugin-fullscreen": "^1.3.0",
|
||||||
"isomorphic-xml2js": "^0.1.3",
|
"isomorphic-xml2js": "^0.1.3",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"memoizee": "^0.4.15",
|
"memoizee": "^0.4.15",
|
||||||
"ol": "^8.1.0",
|
"ol": "^7.2.2",
|
||||||
"osmtogeojson": "^3.0.0-beta.5",
|
"osmtogeojson": "^3.0.0-beta.5",
|
||||||
"patch-package": "^8.0.0",
|
"pouchdb": "^8.0.0",
|
||||||
"piexifjs": "^1.0.6",
|
"pouchdb-browser": "^8.0.0",
|
||||||
"pluscodes": "^2.6.0",
|
"proj4": "^2.8.1",
|
||||||
"pouchdb": "^8.0.1",
|
"solid-js": "^1.6.10",
|
||||||
"pouchdb-adapter-indexeddb": "^8.0.1",
|
"vite-plugin-solid-svg": "^0.6.0"
|
||||||
"pouchdb-browser": "^8.0.1",
|
|
||||||
"proj4": "^2.9.0",
|
|
||||||
"solid-js": "^1.7.12",
|
|
||||||
"vite-plugin-solid-svg": "^0.6.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
diff --git a/node_modules/@suid/material/InputBase/InputBase.jsx b/node_modules/@suid/material/InputBase/InputBase.jsx
|
|
||||||
index 4d9a4b9..e465053 100644
|
|
||||||
--- a/node_modules/@suid/material/InputBase/InputBase.jsx
|
|
||||||
+++ b/node_modules/@suid/material/InputBase/InputBase.jsx
|
|
||||||
@@ -239,7 +239,7 @@ const inputGlobalStyles = () => (<>
|
|
||||||
"@keyframes mui-auto-fill-cancel": { from: { display: "block" } },
|
|
||||||
}}/>}
|
|
||||||
</>);
|
|
||||||
-const selectionTypes = new Set(["text", "search", "password", "tel", "url"]);
|
|
||||||
+const selectionTypes = new Set(["text", "textarea", "search", "password", "tel", "url"]);
|
|
||||||
/**
|
|
||||||
* `InputBase` contains as few styles as possible.
|
|
||||||
* It aims to be a simple building block for creating an input.
|
|
|
@ -1,33 +0,0 @@
|
||||||
diff --git a/node_modules/piexifjs/piexif.js b/node_modules/piexifjs/piexif.js
|
|
||||||
index 3d0bd12..a920f5e 100644
|
|
||||||
--- a/node_modules/piexifjs/piexif.js
|
|
||||||
+++ b/node_modules/piexifjs/piexif.js
|
|
||||||
@@ -1781,6 +1781,18 @@ SOFTWARE.
|
|
||||||
'name': 'DateTimeDigitized',
|
|
||||||
'type': 'Ascii'
|
|
||||||
},
|
|
||||||
+ 36880: {
|
|
||||||
+ 'name': 'OffsetTime',
|
|
||||||
+ 'type': 'Ascii'
|
|
||||||
+ },
|
|
||||||
+ 36881: {
|
|
||||||
+ 'name': 'OffsetTimeOriginal',
|
|
||||||
+ 'type': 'Ascii'
|
|
||||||
+ },
|
|
||||||
+ 36882: {
|
|
||||||
+ 'name': 'OffsetTimeDigitized',
|
|
||||||
+ 'type': 'Ascii'
|
|
||||||
+ },
|
|
||||||
37121: {
|
|
||||||
'name': 'ComponentsConfiguration',
|
|
||||||
'type': 'Undefined'
|
|
||||||
@@ -2349,6 +2361,9 @@ SOFTWARE.
|
|
||||||
ExifVersion:36864,
|
|
||||||
DateTimeOriginal:36867,
|
|
||||||
DateTimeDigitized:36868,
|
|
||||||
+ OffsetTime:36880,
|
|
||||||
+ OffsetTimeOriginal:36881,
|
|
||||||
+ OffsetTimeDigitized:36882,
|
|
||||||
ComponentsConfiguration:37121,
|
|
||||||
CompressedBitsPerPixel:37122,
|
|
||||||
ShutterSpeedValue:37377,
|
|
|
@ -2,15 +2,13 @@ import { Component, createSignal, For } from 'solid-js';
|
||||||
|
|
||||||
import PersonIcon from '@suid/icons-material/Person';
|
import PersonIcon from '@suid/icons-material/Person';
|
||||||
|
|
||||||
|
import style from './Account.module.css';
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
DialogActions,
|
DialogActions,
|
||||||
|
IconButton,
|
||||||
InputLabel,
|
InputLabel,
|
||||||
ListItem,
|
|
||||||
ListItemButton,
|
|
||||||
ListItemIcon,
|
|
||||||
ListItemText,
|
|
||||||
NativeSelect,
|
NativeSelect,
|
||||||
TextField,
|
TextField,
|
||||||
} from '@suid/material';
|
} from '@suid/material';
|
||||||
|
@ -36,10 +34,6 @@ const Account: Component<{}> = (props) => {
|
||||||
const newAccounts: any = await dispatch({
|
const newAccounts: any = await dispatch({
|
||||||
action: 'getAccounts',
|
action: 'getAccounts',
|
||||||
});
|
});
|
||||||
console.log({
|
|
||||||
caller: 'Account / handleClickOpen',
|
|
||||||
newAccounts,
|
|
||||||
});
|
|
||||||
setAccounts([{ id: '--new--', name: t('newAccount') }, ...newAccounts]);
|
setAccounts([{ id: '--new--', name: t('newAccount') }, ...newAccounts]);
|
||||||
setAccount(
|
setAccount(
|
||||||
cloneDeep(getAccountById(accounts(), settings().currentAccountId))
|
cloneDeep(getAccountById(accounts(), settings().currentAccountId))
|
||||||
|
@ -125,15 +119,11 @@ const Account: Component<{}> = (props) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ListItem>
|
<div class={style.control}>
|
||||||
<ListItemButton onClick={handleClickOpen}>
|
<IconButton onClick={handleClickOpen}>
|
||||||
<ListItemIcon>
|
<PersonIcon />
|
||||||
<PersonIcon />
|
</IconButton>
|
||||||
</ListItemIcon>
|
</div>
|
||||||
<ListItemText>Account</ListItemText>
|
|
||||||
</ListItemButton>
|
|
||||||
</ListItem>
|
|
||||||
|
|
||||||
<Dialog
|
<Dialog
|
||||||
open={open()}
|
open={open()}
|
||||||
title={t('account')}
|
title={t('account')}
|
||||||
|
|
|
@ -8,34 +8,43 @@ import { useI18n } from '@solid-primitives/i18n';
|
||||||
import dispatch from '../../workers/dispatcher-main';
|
import dispatch from '../../workers/dispatcher-main';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
wpt: () => Wpt;
|
target: () => any;
|
||||||
dispatchParams: (wpt: Wpt) => { action: string; params: any };
|
putAction: string;
|
||||||
|
putParamName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DisplayOrGetAddress: Component<Props> = ({ wpt, dispatchParams }) => {
|
const DisplayOrGetAddress: Component<Props> = ({
|
||||||
|
target,
|
||||||
|
putAction,
|
||||||
|
putParamName,
|
||||||
|
}) => {
|
||||||
const [t, { add, locale, dict }] = useI18n();
|
const [t, { add, locale, dict }] = useI18n();
|
||||||
|
|
||||||
const findClickHandler = async () => {
|
const findClickHandler = async () => {
|
||||||
console.log({ caller: 'findClickHandler', wpt: wpt() });
|
const address = await findAddress(target().$.lon, target().$.lat, locale);
|
||||||
const address = await findAddress(wpt().$.lon, wpt().$.lat, locale);
|
const updatedTarget = cloneDeep(target());
|
||||||
const updatedTarget = cloneDeep(wpt());
|
|
||||||
if (updatedTarget.extensions === undefined) {
|
if (updatedTarget.extensions === undefined) {
|
||||||
updatedTarget.extensions = {};
|
updatedTarget.extensions = {};
|
||||||
}
|
}
|
||||||
updatedTarget.extensions.address = address;
|
updatedTarget.extensions.address = address;
|
||||||
dispatch(dispatchParams(updatedTarget));
|
const params: any = { id: target().id };
|
||||||
|
params[putParamName] = updatedTarget;
|
||||||
|
dispatch({
|
||||||
|
action: putAction,
|
||||||
|
params,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Show
|
<Show
|
||||||
when={wpt()?.extensions?.address}
|
when={target().extensions?.address}
|
||||||
fallback={
|
fallback={
|
||||||
<IconButton color='primary' onClick={findClickHandler}>
|
<IconButton color='primary' onClick={findClickHandler}>
|
||||||
<SearchIcon />
|
<SearchIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<>{getVillageOrTown(wpt()?.extensions?.address)}</>
|
<>{getVillageOrTown(target().extensions?.address)}</>
|
||||||
</Show>
|
</Show>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
import { Component } from 'solid-js';
|
|
||||||
import { useI18n } from '@solid-primitives/i18n';
|
|
||||||
import DisplayOrGetAddress from '.';
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
id: string;
|
|
||||||
wpts: () => Wpt[];
|
|
||||||
putAction: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const DisplayOrGetStartEndAddresses: Component<Props> = (props) => {
|
|
||||||
const { id, wpts, putAction } = props;
|
|
||||||
const [t, { add, locale, dict }] = useI18n();
|
|
||||||
|
|
||||||
const dispatchParamsFactory = (index: number) => (wpt: Wpt) => ({
|
|
||||||
action: putAction,
|
|
||||||
params: { id, index, wpt },
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{t('from')}{' '}
|
|
||||||
<DisplayOrGetAddress
|
|
||||||
wpt={() => wpts()?.at(0)}
|
|
||||||
dispatchParams={dispatchParamsFactory(0)}
|
|
||||||
/>{' '}
|
|
||||||
{t('to')}{' '}
|
|
||||||
<DisplayOrGetAddress
|
|
||||||
wpt={() => wpts()?.at(-1)}
|
|
||||||
dispatchParams={dispatchParamsFactory(-1)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DisplayOrGetStartEndAddresses;
|
|
|
@ -1,2 +1 @@
|
||||||
export { default } from './DisplayOrGetAddress';
|
export { default } from './DisplayOrGetAddress';
|
||||||
export { default as DisplayOrGetStartEndAddresses } from './DisplayOrGetStartEndAddresses';
|
|
||||||
|
|
|
@ -1,222 +0,0 @@
|
||||||
import { Component, createEffect } from 'solid-js';
|
|
||||||
|
|
||||||
import style from './index.module.css';
|
|
||||||
import Tree from '../tree/Tree';
|
|
||||||
import getUri from '../../lib/ids';
|
|
||||||
import { createCachedSignal } from '../../workers/cached-signals';
|
|
||||||
import { FormControlLabel, Radio, RadioGroup } from '@suid/material';
|
|
||||||
import { getDrawingSelections } from '../../db/drawing-selections';
|
|
||||||
import dispatch from '../../workers/dispatcher-main';
|
|
||||||
import { Feature } from 'ol';
|
|
||||||
import uri from '../../lib/ids';
|
|
||||||
import { currentGpxId } from '../gpx-dialog';
|
|
||||||
|
|
||||||
const id = getUri('drawingSelections', undefined);
|
|
||||||
|
|
||||||
type CompleteSelectionType = 'ALL' | 'NONE' | 'CURRENT';
|
|
||||||
|
|
||||||
type RestrictedSelectionType = 'ALL' | 'NONE';
|
|
||||||
|
|
||||||
type DrawingSelections = {
|
|
||||||
gpxSelection: CompleteSelectionType;
|
|
||||||
trkSelection: RestrictedSelectionType;
|
|
||||||
rteSelection: RestrictedSelectionType;
|
|
||||||
wptSelection: RestrictedSelectionType;
|
|
||||||
};
|
|
||||||
|
|
||||||
const defaultDrawingSelections: DrawingSelections = {
|
|
||||||
gpxSelection: 'ALL',
|
|
||||||
trkSelection: 'ALL',
|
|
||||||
rteSelection: 'ALL',
|
|
||||||
wptSelection: 'ALL',
|
|
||||||
};
|
|
||||||
|
|
||||||
const drawingSelections = createCachedSignal({
|
|
||||||
id,
|
|
||||||
method: 'getDrawingSelections',
|
|
||||||
defaultDrawingSelections,
|
|
||||||
}) as () => DrawingSelections;
|
|
||||||
|
|
||||||
createEffect(() => {
|
|
||||||
console.log({
|
|
||||||
caller: 'DrawingSelections',
|
|
||||||
drawingSelections: drawingSelections(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const AllNoneCurrent: Component<{}> = (props) => {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<FormControlLabel
|
|
||||||
value='ALL'
|
|
||||||
control={<Radio />}
|
|
||||||
label='All'
|
|
||||||
></FormControlLabel>
|
|
||||||
<FormControlLabel
|
|
||||||
value='NONE'
|
|
||||||
control={<Radio />}
|
|
||||||
label='None'
|
|
||||||
></FormControlLabel>
|
|
||||||
<FormControlLabel
|
|
||||||
value='CURRENT'
|
|
||||||
control={<Radio />}
|
|
||||||
label='Current'
|
|
||||||
></FormControlLabel>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const AllNone: Component<{}> = (props) => {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<FormControlLabel
|
|
||||||
value='ALL'
|
|
||||||
control={<Radio />}
|
|
||||||
label='All'
|
|
||||||
></FormControlLabel>
|
|
||||||
<FormControlLabel
|
|
||||||
value='NONE'
|
|
||||||
control={<Radio />}
|
|
||||||
label='None'
|
|
||||||
></FormControlLabel>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const gpxSelection = () => drawingSelections().gpxSelection;
|
|
||||||
|
|
||||||
const gpxMustBeDrawn = (feature: Feature) => {
|
|
||||||
const id = feature.getId() as String;
|
|
||||||
if (gpxSelection() === 'ALL') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (gpxSelection() === 'CURRENT') {
|
|
||||||
return id.startsWith(currentGpxId());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
const typeMustBeDrawn = (feature: Feature) => {
|
|
||||||
const type = feature.get('type') as String;
|
|
||||||
if (type.startsWith('trk')) {
|
|
||||||
return drawingSelections().trkSelection !== 'NONE';
|
|
||||||
}
|
|
||||||
if (type === 'wpt') {
|
|
||||||
return drawingSelections().wptSelection !== 'NONE';
|
|
||||||
}
|
|
||||||
if (type === 'rte') {
|
|
||||||
return drawingSelections().rteSelection !== 'NONE';
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const mustBeDrawn = (feature: Feature) => {
|
|
||||||
console.log({
|
|
||||||
caller: 'DrawingSelector / mustBeDrawn',
|
|
||||||
feature,
|
|
||||||
});
|
|
||||||
return gpxMustBeDrawn(feature) && typeMustBeDrawn(feature);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleGpxSelectionChange = (ev: any) => {
|
|
||||||
const value = ev.target.value;
|
|
||||||
console.log({
|
|
||||||
caller: 'DrawingSelector / handleGpxSelectionChange',
|
|
||||||
ev,
|
|
||||||
value,
|
|
||||||
});
|
|
||||||
const newDrawingSelections = drawingSelections();
|
|
||||||
newDrawingSelections.gpxSelection = value;
|
|
||||||
dispatch({
|
|
||||||
action: 'putDrawingSelections',
|
|
||||||
params: { id, drawingSelections: newDrawingSelections },
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleTrkSelectionChange = (ev: any) => {
|
|
||||||
const value = ev.target.value;
|
|
||||||
console.log({
|
|
||||||
caller: 'DrawingSelector / handleTrkSelectionChange',
|
|
||||||
ev,
|
|
||||||
value,
|
|
||||||
});
|
|
||||||
const newDrawingSelections = drawingSelections();
|
|
||||||
newDrawingSelections.trkSelection = value;
|
|
||||||
dispatch({
|
|
||||||
action: 'putDrawingSelections',
|
|
||||||
params: { id, drawingSelections: newDrawingSelections },
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleRteSelectionChange = (ev: any) => {
|
|
||||||
const value = ev.target.value;
|
|
||||||
console.log({
|
|
||||||
caller: 'DrawingSelector / handleRteSelectionChange',
|
|
||||||
ev,
|
|
||||||
value,
|
|
||||||
});
|
|
||||||
const newDrawingSelections = drawingSelections();
|
|
||||||
newDrawingSelections.rteSelection = value;
|
|
||||||
dispatch({
|
|
||||||
action: 'putDrawingSelections',
|
|
||||||
params: { id, drawingSelections: newDrawingSelections },
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleWptSelectionChange = (ev: any) => {
|
|
||||||
const value = ev.target.value;
|
|
||||||
console.log({
|
|
||||||
caller: 'DrawingSelector / handleWptSelectionChange',
|
|
||||||
ev,
|
|
||||||
value,
|
|
||||||
});
|
|
||||||
const newDrawingSelections = drawingSelections();
|
|
||||||
newDrawingSelections.wptSelection = value;
|
|
||||||
dispatch({
|
|
||||||
action: 'putDrawingSelections',
|
|
||||||
params: { id, drawingSelections: newDrawingSelections },
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const DrawingSelector: Component<{}> = (props) => {
|
|
||||||
return (
|
|
||||||
<Tree
|
|
||||||
title='Show'
|
|
||||||
content={
|
|
||||||
<>
|
|
||||||
<div>Trips</div>
|
|
||||||
<RadioGroup
|
|
||||||
defaultValue={drawingSelections()?.gpxSelection}
|
|
||||||
onChange={handleGpxSelectionChange}
|
|
||||||
>
|
|
||||||
<AllNoneCurrent />
|
|
||||||
</RadioGroup>
|
|
||||||
<div>Tracks</div>
|
|
||||||
<RadioGroup
|
|
||||||
defaultValue={drawingSelections()?.trkSelection}
|
|
||||||
onChange={handleTrkSelectionChange}
|
|
||||||
>
|
|
||||||
<AllNone />
|
|
||||||
</RadioGroup>
|
|
||||||
<div>Routes</div>
|
|
||||||
<RadioGroup
|
|
||||||
defaultValue={drawingSelections()?.rteSelection}
|
|
||||||
onChange={handleRteSelectionChange}
|
|
||||||
>
|
|
||||||
<AllNone />
|
|
||||||
</RadioGroup>{' '}
|
|
||||||
<div>Waypoints</div>
|
|
||||||
<RadioGroup
|
|
||||||
defaultValue={drawingSelections()?.wptSelection}
|
|
||||||
onChange={handleWptSelectionChange}
|
|
||||||
>
|
|
||||||
<AllNone />
|
|
||||||
</RadioGroup>
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
subTree={undefined}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DrawingSelector;
|
|
|
@ -1,3 +0,0 @@
|
||||||
import { mustBeDrawn } from './DrawingSelector';
|
|
||||||
|
|
||||||
export { default, mustBeDrawn } from './DrawingSelector';
|
|
|
@ -5,13 +5,6 @@
|
||||||
margin-left: calc(100% - 230px) !important;
|
margin-left: calc(100% - 230px) !important;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
.control_web {
|
|
||||||
opacity: 1;
|
|
||||||
position: fixed !important;
|
|
||||||
top: 0px;
|
|
||||||
margin-left: calc(100% - 190px) !important;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
.ol_popup {
|
.ol_popup {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
|
|
|
@ -7,16 +7,12 @@ import { useI18n } from '@solid-primitives/i18n';
|
||||||
import proj4 from 'proj4';
|
import proj4 from 'proj4';
|
||||||
|
|
||||||
import style from './Finder.module.css';
|
import style from './Finder.module.css';
|
||||||
import './finder.css';
|
|
||||||
|
|
||||||
import { Box, Button, IconButton, TextField } from '@suid/material';
|
import { Box, Button, IconButton, TextField } from '@suid/material';
|
||||||
import Dialog from '../dialog';
|
import Dialog from '../dialog';
|
||||||
import { getMap, getState } from '../map';
|
import { getMap, getState } from '../map';
|
||||||
import { Overlay } from 'ol';
|
import { Overlay } from 'ol';
|
||||||
import { fromLonLat } from 'ol/proj';
|
import { fromLonLat } from 'ol/proj';
|
||||||
import WptEditDialog from '../wpt/WptEditDialog';
|
import WptEditDialog from '../wpt/WptEditDialog';
|
||||||
import maybePlusCode from '../../lib/check-pluscodes';
|
|
||||||
import { decode, expand } from 'pluscodes';
|
|
||||||
|
|
||||||
const [popup, setPopup] = createSignal<Overlay>();
|
const [popup, setPopup] = createSignal<Overlay>();
|
||||||
const [open, setOpen] = createSignal(false);
|
const [open, setOpen] = createSignal(false);
|
||||||
|
@ -70,7 +66,6 @@ const Finder: Component<Props> = (props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const submitHandler = () => {
|
const submitHandler = () => {
|
||||||
setCoordinate(undefined);
|
|
||||||
const latLonRegExp = /(-?[0-9]+.[0-9]+)\s*,\s*(-?[0-9]+.[0-9]+)/;
|
const latLonRegExp = /(-?[0-9]+.[0-9]+)\s*,\s*(-?[0-9]+.[0-9]+)/;
|
||||||
const latLonMatch = searchString().match(latLonRegExp);
|
const latLonMatch = searchString().match(latLonRegExp);
|
||||||
|
|
||||||
|
@ -92,46 +87,15 @@ const Finder: Component<Props> = (props) => {
|
||||||
setPopupContent(
|
setPopupContent(
|
||||||
<>{`${coordinate()[0]}, ${coordinate()[1]} (UTM ${utmMatch[0]})`}</>
|
<>{`${coordinate()[0]}, ${coordinate()[1]} (UTM ${utmMatch[0]})`}</>
|
||||||
);
|
);
|
||||||
console.log({
|
|
||||||
caller: 'Finder / submitHandler',
|
|
||||||
searchString: searchString(),
|
|
||||||
utmMatch,
|
|
||||||
coordinate: coordinate(),
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const potentialPlusCode = maybePlusCode(searchString());
|
|
||||||
if (!!potentialPlusCode) {
|
|
||||||
let plusCode = potentialPlusCode.code;
|
|
||||||
if (potentialPlusCode.isShort) {
|
|
||||||
plusCode = expand(potentialPlusCode.code, {
|
|
||||||
longitude: getState().lon,
|
|
||||||
latitude: getState().lat,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const plusCodeCoordinates = decode(plusCode);
|
|
||||||
if (plusCodeCoordinates) {
|
|
||||||
setCoordinate([
|
|
||||||
plusCodeCoordinates.longitude,
|
|
||||||
plusCodeCoordinates.latitude,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
console.log({
|
|
||||||
caller: 'Finder / submitHandler',
|
|
||||||
searchString: searchString(),
|
|
||||||
potentialPlusCode,
|
|
||||||
plusCode,
|
|
||||||
plusCodeCoordinates,
|
|
||||||
state: getState(),
|
|
||||||
coordinate: coordinate(),
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.log({
|
|
||||||
caller: 'Finder / submitHandler / no match found',
|
|
||||||
searchString: searchString(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
console.log({
|
||||||
|
caller: 'Finder / submitHandler',
|
||||||
|
searchString: searchString(),
|
||||||
|
utmMatch,
|
||||||
|
coordinate: coordinate(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!!coordinate()) {
|
if (!!coordinate()) {
|
||||||
findLocation(navigate, coordinate());
|
findLocation(navigate, coordinate());
|
||||||
}
|
}
|
||||||
|
@ -146,13 +110,7 @@ const Finder: Component<Props> = (props) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div class={style.control}>
|
||||||
class={
|
|
||||||
window.Capacitor.platform === 'web'
|
|
||||||
? style.control_web
|
|
||||||
: style.control
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
|
@ -181,12 +139,9 @@ const Finder: Component<Props> = (props) => {
|
||||||
method='dialog'
|
method='dialog'
|
||||||
>
|
>
|
||||||
<TextField onChange={searchStringChangeHandler} />
|
<TextField onChange={searchStringChangeHandler} />
|
||||||
<Button variant='contained' onClick={submitHandler}>
|
|
||||||
Search
|
|
||||||
</Button>
|
|
||||||
</Box>
|
</Box>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
<div class={style.ol_popup + ' ol_popup'} ref={popupElement}>
|
<div class={style.ol_popup} ref={popupElement}>
|
||||||
<a
|
<a
|
||||||
href='#'
|
href='#'
|
||||||
onclick={popupCloseHandler}
|
onclick={popupCloseHandler}
|
||||||
|
@ -213,4 +168,5 @@ const Finder: Component<Props> = (props) => {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Finder;
|
export default Finder;
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
.ol-map > .ol_popup {
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
|
@ -23,11 +23,6 @@ const GpxChooser: Component<Props> = (props: Props) => {
|
||||||
action: 'getAllGpxesWithSummary',
|
action: 'getAllGpxesWithSummary',
|
||||||
},
|
},
|
||||||
(error, result) => {
|
(error, result) => {
|
||||||
console.log({
|
|
||||||
caller: 'GpxChooser / getAllGpxesWithSummary',
|
|
||||||
error,
|
|
||||||
result,
|
|
||||||
});
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
setAllGpxes([
|
setAllGpxes([
|
||||||
{ id: 'new', name: t('newGpx'), creator: 'dyomedea' },
|
{ id: 'new', name: t('newGpx'), creator: 'dyomedea' },
|
||||||
|
|
|
@ -1,15 +1,6 @@
|
||||||
import { useI18n } from '@solid-primitives/i18n';
|
import { useI18n } from '@solid-primitives/i18n';
|
||||||
import {
|
import { Box, Button, IconButton, SvgIcon, TextField } from '@suid/material';
|
||||||
Box,
|
import { cloneDeep } from 'lodash';
|
||||||
Button,
|
|
||||||
FormControlLabel,
|
|
||||||
IconButton,
|
|
||||||
Radio,
|
|
||||||
RadioGroup,
|
|
||||||
SvgIcon,
|
|
||||||
TextField,
|
|
||||||
} from '@suid/material';
|
|
||||||
import { cloneDeep, isPlainObject } from 'lodash';
|
|
||||||
import { Component, createSignal, Show } from 'solid-js';
|
import { Component, createSignal, Show } from 'solid-js';
|
||||||
import { newEmptyGpx } from '../../db/gpx';
|
import { newEmptyGpx } from '../../db/gpx';
|
||||||
import { peekCachedSignal } from '../../workers/cached-signals';
|
import { peekCachedSignal } from '../../workers/cached-signals';
|
||||||
|
@ -19,12 +10,6 @@ import GpxChooser from '../gpx-chooser';
|
||||||
import GpxIcon from '../gpx/GpxIcon';
|
import GpxIcon from '../gpx/GpxIcon';
|
||||||
//import GpxesIcon from '../../icons/adventure-journey-location-svgrepo-com.svg';
|
//import GpxesIcon from '../../icons/adventure-journey-location-svgrepo-com.svg';
|
||||||
import style from './GpxDialog.module.css';
|
import style from './GpxDialog.module.css';
|
||||||
import {
|
|
||||||
getTagValue,
|
|
||||||
getTagsFromObj,
|
|
||||||
setTagValue,
|
|
||||||
setTagsIntoObj,
|
|
||||||
} from '../../lib/tags/tags';
|
|
||||||
|
|
||||||
export const [currentGpxId, setCurrentGpxId] = createSignal<string>('new');
|
export const [currentGpxId, setCurrentGpxId] = createSignal<string>('new');
|
||||||
|
|
||||||
|
@ -34,12 +19,11 @@ const GpxDialog: Component<{}> = (props) => {
|
||||||
|
|
||||||
const [selectedGpxId, setSelectedGpxId] = createSignal<string>('');
|
const [selectedGpxId, setSelectedGpxId] = createSignal<string>('');
|
||||||
const [gpx, setGpx] = createSignal<Gpx>();
|
const [gpx, setGpx] = createSignal<Gpx>();
|
||||||
const [currentAccount, setCurrentAccount] = createSignal<any>();
|
|
||||||
|
|
||||||
console.log({ caller: 'GpxDialog', currentGpxId: currentGpxId() });
|
console.log({ caller: 'GpxDialog', currentGpxId: currentGpxId() });
|
||||||
|
|
||||||
const fetchGpx = (gpxId: string) => {
|
const fetchGpx = (gpxId: string) => {
|
||||||
if (gpxId === 'new' || !gpxId) {
|
if (gpxId === 'new') {
|
||||||
return newEmptyGpx();
|
return newEmptyGpx();
|
||||||
}
|
}
|
||||||
const newGpx = peekCachedSignal({
|
const newGpx = peekCachedSignal({
|
||||||
|
@ -49,16 +33,12 @@ const GpxDialog: Component<{}> = (props) => {
|
||||||
return newGpx();
|
return newGpx();
|
||||||
};
|
};
|
||||||
|
|
||||||
dispatch({ action: 'getCurrentAccount' }).then((currentAccount: any) => {
|
|
||||||
console.log({ caller: 'GpxDialog / currentAccount', currentAccount });
|
|
||||||
setCurrentAccount(currentAccount);
|
|
||||||
setCurrentGpxId(currentAccount.currentGpxId || 'new');
|
|
||||||
setSelectedGpxId(currentAccount.currentGpxId || 'new');
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleClickOpen = async () => {
|
const handleClickOpen = async () => {
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
setGpx(fetchGpx(currentGpxId()) as Gpx);
|
setSelectedGpxId(currentGpxId());
|
||||||
|
if (currentGpxId() !== '') {
|
||||||
|
setGpx(fetchGpx(currentGpxId()) as Gpx);
|
||||||
|
}
|
||||||
console.log({
|
console.log({
|
||||||
caller: 'GpxDialog / handleClickOpen',
|
caller: 'GpxDialog / handleClickOpen',
|
||||||
currentGpxId: currentGpxId(),
|
currentGpxId: currentGpxId(),
|
||||||
|
@ -113,20 +93,6 @@ const GpxDialog: Component<{}> = (props) => {
|
||||||
gpx: gpx(),
|
gpx: gpx(),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const gpxToChangeHandler = (event: any) => {
|
|
||||||
const newGpx: Gpx = cloneDeep(gpx()) as Gpx;
|
|
||||||
if (!isPlainObject(newGpx.extensions)) {
|
|
||||||
newGpx.extensions = {};
|
|
||||||
}
|
|
||||||
newGpx.extensions.to = event.target.value;
|
|
||||||
setGpx(newGpx);
|
|
||||||
console.log({
|
|
||||||
caller: 'GpxDialog / gpxToChangeHandler',
|
|
||||||
value: event.target.value,
|
|
||||||
gpx: gpx(),
|
|
||||||
newGpx,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const gpxTimeChangeHandler = (event: any) => {
|
const gpxTimeChangeHandler = (event: any) => {
|
||||||
const newGpx: Gpx = cloneDeep(gpx()) as Gpx;
|
const newGpx: Gpx = cloneDeep(gpx()) as Gpx;
|
||||||
if (newGpx.metadata === undefined) {
|
if (newGpx.metadata === undefined) {
|
||||||
|
@ -141,18 +107,6 @@ const GpxDialog: Component<{}> = (props) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getGpxTagValue = (tagName: string, defaultValue: string) => {
|
|
||||||
return getTagValue(getTagsFromObj(gpx()), tagName) || defaultValue;
|
|
||||||
};
|
|
||||||
|
|
||||||
const gpxLocomotionChangeHandler = (event: any) => {
|
|
||||||
const newGpx: Gpx = cloneDeep(gpx()) as Gpx;
|
|
||||||
const tags = getTagsFromObj(newGpx);
|
|
||||||
setTagValue(tags, 'locomotion', event.target.value);
|
|
||||||
setTagsIntoObj(newGpx, tags);
|
|
||||||
setGpx(newGpx);
|
|
||||||
};
|
|
||||||
|
|
||||||
const saveHandler = async (event: any) => {
|
const saveHandler = async (event: any) => {
|
||||||
const id = (await dispatch({
|
const id = (await dispatch({
|
||||||
action: 'putGpx',
|
action: 'putGpx',
|
||||||
|
@ -163,12 +117,6 @@ const GpxDialog: Component<{}> = (props) => {
|
||||||
})) as string;
|
})) as string;
|
||||||
setCurrentGpxId(id);
|
setCurrentGpxId(id);
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
await dispatch({
|
|
||||||
action: 'putCurrentAccount',
|
|
||||||
params: {
|
|
||||||
account: { ...currentAccount(), currentGpxId: currentGpxId() },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -216,30 +164,6 @@ const GpxDialog: Component<{}> = (props) => {
|
||||||
onChange={gpxDescChangeHandler}
|
onChange={gpxDescChangeHandler}
|
||||||
InputProps={{ inputComponent: 'textarea' }}
|
InputProps={{ inputComponent: 'textarea' }}
|
||||||
/>
|
/>
|
||||||
<div>Locomotion</div>
|
|
||||||
<RadioGroup
|
|
||||||
value={getGpxTagValue('locomotion', 'hiking')}
|
|
||||||
onChange={gpxLocomotionChangeHandler}
|
|
||||||
>
|
|
||||||
<FormControlLabel
|
|
||||||
value='hiking'
|
|
||||||
control={<Radio />}
|
|
||||||
label='Hiking'
|
|
||||||
></FormControlLabel>
|
|
||||||
<FormControlLabel
|
|
||||||
value='cycling'
|
|
||||||
control={<Radio />}
|
|
||||||
label='Cycling'
|
|
||||||
></FormControlLabel>
|
|
||||||
</RadioGroup>
|
|
||||||
<TextField
|
|
||||||
label={t('gpxTo')}
|
|
||||||
multiline={true}
|
|
||||||
rows={5}
|
|
||||||
value={gpx()?.extensions?.to || ''}
|
|
||||||
onChange={gpxToChangeHandler}
|
|
||||||
InputProps={{ inputComponent: 'textarea' }}
|
|
||||||
/>
|
|
||||||
<Button variant='contained' onClick={saveHandler}>
|
<Button variant='contained' onClick={saveHandler}>
|
||||||
{t('gpxSave')}
|
{t('gpxSave')}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -4,11 +4,11 @@ import CloudUploadIcon from '@suid/icons-material/CloudUpload';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
||||||
import css from './Import.module.css';
|
import css from './GpxImport.module.css';
|
||||||
import Dialog from '../dialog';
|
import Dialog from '../dialog';
|
||||||
import { useI18n } from '@solid-primitives/i18n';
|
import { useI18n } from '@solid-primitives/i18n';
|
||||||
import { Box } from '@suid/material';
|
import { Box } from '@suid/material';
|
||||||
import ImportSingleFile from './ImportSingleFile';
|
import GpxImportSingleFile from './GpxImportSingleFile';
|
||||||
|
|
||||||
const [filesToImport, setFilesToImport] = createSignal<FileList | string[]>();
|
const [filesToImport, setFilesToImport] = createSignal<FileList | string[]>();
|
||||||
|
|
||||||
|
@ -38,11 +38,6 @@ const GpxImport: Component = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const accept =
|
|
||||||
window.Capacitor.platform === 'android'
|
|
||||||
? ''
|
|
||||||
: '.gpx,.jpg,image/jpeg,application/gpx+xml';
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div class={css.container}>
|
<div class={css.container}>
|
||||||
|
@ -53,7 +48,7 @@ const GpxImport: Component = () => {
|
||||||
type='file'
|
type='file'
|
||||||
id='gpx-import'
|
id='gpx-import'
|
||||||
class={css.inputFile}
|
class={css.inputFile}
|
||||||
accept={accept}
|
accept='.gpx'
|
||||||
multiple={true}
|
multiple={true}
|
||||||
onChange={onChangeHandler}
|
onChange={onChangeHandler}
|
||||||
/>
|
/>
|
||||||
|
@ -70,7 +65,7 @@ const GpxImport: Component = () => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<For each={filesToImport()}>
|
<For each={filesToImport()}>
|
||||||
{(file) => <ImportSingleFile file={file} />}
|
{(gpxFile) => <GpxImportSingleFile gpxFile={gpxFile} />}
|
||||||
</For>
|
</For>
|
||||||
</Box>
|
</Box>
|
||||||
</Dialog>
|
</Dialog>
|
|
@ -0,0 +1,208 @@
|
||||||
|
import { useI18n } from '@solid-primitives/i18n';
|
||||||
|
import {
|
||||||
|
Typography,
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardActions,
|
||||||
|
Button,
|
||||||
|
Box,
|
||||||
|
LinearProgress,
|
||||||
|
CircularProgress,
|
||||||
|
} from '@suid/material';
|
||||||
|
import { Component, createEffect, createSignal, Show } from 'solid-js';
|
||||||
|
import { findStartTime } from '../../lib/gpx';
|
||||||
|
import GPX from '../../lib/gpx-parser-builder/src/gpx';
|
||||||
|
import dispatch from '../../workers/dispatcher-main';
|
||||||
|
import GpxChooser from '../gpx-chooser';
|
||||||
|
import { currentGpxId } from '../gpx-dialog';
|
||||||
|
import {
|
||||||
|
Filesystem as CapacitorFileSystem,
|
||||||
|
Encoding,
|
||||||
|
} from '@capacitor/filesystem';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
gpxFile: File;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StatsAndGpx {
|
||||||
|
gpx: Gpx;
|
||||||
|
stats: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
const analyzeGpx = (gpx: Gpx | undefined) => {
|
||||||
|
if (gpx === undefined) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
const stats = {
|
||||||
|
creator: gpx.$.creator,
|
||||||
|
nbWpts: gpx.wpt ? gpx.wpt?.length : 0,
|
||||||
|
nbRtes: gpx.rte ? gpx.rte?.length : 0,
|
||||||
|
nbTrks: gpx.trk ? gpx.trk?.length : 0,
|
||||||
|
trkMaybeRte:
|
||||||
|
gpx.trk &&
|
||||||
|
gpx.trk[0].trkseg &&
|
||||||
|
gpx.trk[0].trkseg[0] &&
|
||||||
|
gpx.trk[0].trkseg[0].trkpt &&
|
||||||
|
!gpx.trk[0].trkseg[0].trkpt[0].time,
|
||||||
|
startTime: findStartTime(gpx),
|
||||||
|
};
|
||||||
|
|
||||||
|
return stats;
|
||||||
|
};
|
||||||
|
|
||||||
|
const GpxImportSingleFile: Component<Props> = ({ gpxFile }) => {
|
||||||
|
const [t] = useI18n();
|
||||||
|
const [statsAndGpx, setStatsAndGpx] = createSignal<StatsAndGpx>();
|
||||||
|
const [state, setState] = createSignal('init');
|
||||||
|
const [gpxId, setGpxId] = createSignal<string>('');
|
||||||
|
createEffect(() => {
|
||||||
|
setGpxId(currentGpxId());
|
||||||
|
});
|
||||||
|
|
||||||
|
const parseGpx = (content: string) => {
|
||||||
|
const gpx = GPX.parse(content);
|
||||||
|
console.log({ caller: 'GpxImportSingleFile / JSON', gpxFile, gpx });
|
||||||
|
setStatsAndGpx({ gpx, stats: analyzeGpx(gpx) });
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof gpxFile === 'string') {
|
||||||
|
CapacitorFileSystem.requestPermissions().then((permissionStatus) => {
|
||||||
|
console.log({
|
||||||
|
caller: 'GpxImportSingleFile / content',
|
||||||
|
permissionStatus,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
CapacitorFileSystem.readFile({
|
||||||
|
path: gpxFile,
|
||||||
|
encoding: Encoding.UTF8,
|
||||||
|
}).then((content) => {
|
||||||
|
console.log({
|
||||||
|
caller: 'GpxImportSingleFile / content',
|
||||||
|
gpxFile,
|
||||||
|
content,
|
||||||
|
});
|
||||||
|
parseGpx(content.data);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const gpxReader = new FileReader();
|
||||||
|
gpxReader.readAsText(gpxFile);
|
||||||
|
gpxReader.addEventListener(
|
||||||
|
'load',
|
||||||
|
async () => {
|
||||||
|
// this will then display a text gpxfile
|
||||||
|
console.log({
|
||||||
|
caller: 'GpxImportSingleFile / XML',
|
||||||
|
gpxFile,
|
||||||
|
result: gpxReader.result,
|
||||||
|
});
|
||||||
|
parseGpx(gpxReader.result);
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const doImport = async () => {
|
||||||
|
setState('importing');
|
||||||
|
// console.log({ caller: 'GpxImport / JSON', file, gpx });
|
||||||
|
// if (gpx) {
|
||||||
|
// const startTime = new Date(findStartTime(gpx)!);
|
||||||
|
await dispatch({
|
||||||
|
action: 'pruneAndSaveImportedGpx',
|
||||||
|
params: {
|
||||||
|
id: gpxId(),
|
||||||
|
gpx: statsAndGpx()?.gpx,
|
||||||
|
tech:
|
||||||
|
typeof gpxFile === 'string'
|
||||||
|
? {
|
||||||
|
importDate: new Date().toISOString(),
|
||||||
|
uri: gpxFile,
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
lastModified: new Date(gpxFile.lastModified).toISOString(),
|
||||||
|
importDate: new Date().toISOString(),
|
||||||
|
name: gpxFile.name,
|
||||||
|
size: gpxFile.size,
|
||||||
|
type: gpxFile.type,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log({
|
||||||
|
caller: 'GpxImport / JSON / done',
|
||||||
|
gpxFile,
|
||||||
|
gpx: statsAndGpx()?.gpx,
|
||||||
|
});
|
||||||
|
setState('done');
|
||||||
|
|
||||||
|
// } else {
|
||||||
|
// console.error({
|
||||||
|
// message: "can't parse GPX file",
|
||||||
|
// file,
|
||||||
|
// xml: fileReader.result,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// // TODO: error handling
|
||||||
|
// },
|
||||||
|
// false
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
};
|
||||||
|
|
||||||
|
const [selectedTrkTransform, setSelectedTrkTransform] = createSignal(
|
||||||
|
'importNonTimedTrksAsRtes'
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleTrkTransformChange = (event: any) => {
|
||||||
|
setSelectedTrkTransform(event.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const controlTrkTransformProps = (item: string) => ({
|
||||||
|
checked: selectedTrkTransform() === item,
|
||||||
|
onChange: handleTrkTransformChange,
|
||||||
|
value: item,
|
||||||
|
name: 'trkTransform',
|
||||||
|
label: t(item),
|
||||||
|
inputProps: { 'aria-label': item },
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card raised>
|
||||||
|
<CardContent>
|
||||||
|
<Typography variant='h6'>
|
||||||
|
{t('file')}
|
||||||
|
{gpxFile.name}
|
||||||
|
</Typography>
|
||||||
|
</CardContent>
|
||||||
|
<CardContent>
|
||||||
|
<Show when={statsAndGpx() !== undefined}>
|
||||||
|
<Typography variant='body1'>
|
||||||
|
{t('gpxStats', statsAndGpx().stats)}{' '}
|
||||||
|
{statsAndGpx()?.stats.startTime
|
||||||
|
? t('gpxStartTime', statsAndGpx().stats)
|
||||||
|
: t('gpxNoStartTime')}
|
||||||
|
</Typography>
|
||||||
|
<Show when={statsAndGpx().stats.trkMaybeRte}>
|
||||||
|
<Typography variant='body1'>{t('trkMaybeRte')}</Typography>
|
||||||
|
</Show>
|
||||||
|
<Show when={state() === 'importing'}>
|
||||||
|
<LinearProgress />
|
||||||
|
</Show>
|
||||||
|
<CardActions>
|
||||||
|
<GpxChooser
|
||||||
|
gpxId={gpxId}
|
||||||
|
setGpxId={setGpxId}
|
||||||
|
disabled={state() != 'init'}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
variant='contained'
|
||||||
|
disabled={state() != 'init'}
|
||||||
|
onClick={doImport}
|
||||||
|
>
|
||||||
|
{t('import')}
|
||||||
|
</Button>
|
||||||
|
</CardActions>
|
||||||
|
</Show>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default GpxImportSingleFile;
|
|
@ -0,0 +1 @@
|
||||||
|
export { default, importUrls } from './GpxImport';
|
|
@ -42,10 +42,7 @@ const GpxRecord: Component<{}> = (props) => {
|
||||||
location.time - globalThis.$lastValidLocationTime
|
location.time - globalThis.$lastValidLocationTime
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
if (
|
if (location.time - globalThis.$lastValidLocationTime > 15000) {
|
||||||
location.accuracy < 10 &&
|
|
||||||
location.time - globalThis.$lastValidLocationTime > 15000
|
|
||||||
) {
|
|
||||||
globalThis.$lastValidLocationTime = location.time;
|
globalThis.$lastValidLocationTime = location.time;
|
||||||
await dispatch({
|
await dispatch({
|
||||||
action: 'appendTrkpt',
|
action: 'appendTrkpt',
|
||||||
|
@ -65,7 +62,7 @@ const GpxRecord: Component<{}> = (props) => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
setCurrentLocation({ lon: location.longitude, lat: location.latitude });
|
setCurrentLocation({lon:location.longitude, lat:location.latitude});
|
||||||
const state = getState();
|
const state = getState();
|
||||||
navigate(
|
navigate(
|
||||||
`/map/${state.provider}/${location.longitude}/${location.latitude}/${state.zoom}/${state.rotation}`
|
`/map/${state.provider}/${location.longitude}/${location.latitude}/${state.zoom}/${state.rotation}`
|
||||||
|
@ -90,7 +87,7 @@ const GpxRecord: Component<{}> = (props) => {
|
||||||
const trkIdObj = getUri('trk', trkId);
|
const trkIdObj = getUri('trk', trkId);
|
||||||
setTrksegId({ ...trkIdObj, trkseg: 0 });
|
setTrksegId({ ...trkIdObj, trkseg: 0 });
|
||||||
globalThis.$lastValidLocationTime = 0;
|
globalThis.$lastValidLocationTime = 0;
|
||||||
const id = await startBackgroundGeolocation(newLocationHandler, 10);
|
const id = await startBackgroundGeolocation(newLocationHandler, 20);
|
||||||
setWatcherId(id);
|
setWatcherId(id);
|
||||||
setState('recording');
|
setState('recording');
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
|
@ -102,7 +99,7 @@ const GpxRecord: Component<{}> = (props) => {
|
||||||
};
|
};
|
||||||
const resumeRecordingHandler = async () => {
|
const resumeRecordingHandler = async () => {
|
||||||
setTrksegId({ ...trksegId()!, trkseg: trksegId()!.trkseg + 1 });
|
setTrksegId({ ...trksegId()!, trkseg: trksegId()!.trkseg + 1 });
|
||||||
const id = await startBackgroundGeolocation(newLocationHandler, 10);
|
const id = await startBackgroundGeolocation(newLocationHandler, 20);
|
||||||
setWatcherId(id);
|
setWatcherId(id);
|
||||||
setState('recording');
|
setState('recording');
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
createCachedSignal,
|
createCachedSignal,
|
||||||
destroyCachedSignal,
|
destroyCachedSignal,
|
||||||
} from '../../workers/cached-signals';
|
} from '../../workers/cached-signals';
|
||||||
import { getTagsFromObj } from '../../lib/tags/tags';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
gpxId: string;
|
gpxId: string;
|
||||||
|
@ -38,28 +37,16 @@ export const Gpx: Component<Props> = ({ map, gpxId }) => {
|
||||||
destroyCachedSignal(params);
|
destroyCachedSignal(params);
|
||||||
});
|
});
|
||||||
|
|
||||||
const vectorSources = [new VectorSource(), new VectorSource()];
|
const vectorSource = new VectorSource();
|
||||||
const vectorLayers = [
|
const vectorLayer = new VectorLayer({
|
||||||
new VectorLayer({
|
source: vectorSource,
|
||||||
source: vectorSources[0],
|
style,
|
||||||
style,
|
declutter: true,
|
||||||
declutter: true,
|
|
||||||
zIndex: 1,
|
|
||||||
}),
|
|
||||||
new VectorLayer({
|
|
||||||
source: vectorSources[1],
|
|
||||||
style,
|
|
||||||
declutter: false,
|
|
||||||
zIndex: 2,
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
createEffect(() => {
|
|
||||||
map()?.addLayer(vectorLayers[0]);
|
|
||||||
map()?.addLayer(vectorLayers[1]);
|
|
||||||
});
|
});
|
||||||
|
createEffect(() => map()?.addLayer(vectorLayer));
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
console.log({ caller: 'Gpx', map: map(), gpxId, gpx: gpx(), vectorLayers });
|
console.log({ caller: 'Gpx', map: map(), gpxId, gpx: gpx(), vectorLayer });
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -70,10 +57,9 @@ export const Gpx: Component<Props> = ({ map, gpxId }) => {
|
||||||
return (
|
return (
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<Trk
|
<Trk
|
||||||
vectorSources={vectorSources}
|
vectorSource={vectorSource}
|
||||||
trkId={trkId}
|
trkId={trkId}
|
||||||
context={{ gpx, gpxId }}
|
context={{ gpx, gpxId }}
|
||||||
tags={getTagsFromObj(gpx())}
|
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
);
|
);
|
||||||
|
@ -85,7 +71,7 @@ export const Gpx: Component<Props> = ({ map, gpxId }) => {
|
||||||
return (
|
return (
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<Rte
|
<Rte
|
||||||
vectorSources={vectorSources}
|
vectorSource={vectorSource}
|
||||||
rteId={rteId}
|
rteId={rteId}
|
||||||
context={{ gpx, gpxId }}
|
context={{ gpx, gpxId }}
|
||||||
/>
|
/>
|
||||||
|
@ -99,7 +85,7 @@ export const Gpx: Component<Props> = ({ map, gpxId }) => {
|
||||||
return (
|
return (
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<Wpt
|
<Wpt
|
||||||
vectorSources={vectorSources}
|
vectorSource={vectorSource}
|
||||||
wptId={wptId}
|
wptId={wptId}
|
||||||
context={{ gpx, gpxId }}
|
context={{ gpx, gpxId }}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -57,12 +57,8 @@ import saddle from '../../icons/osm/saddle.svg';
|
||||||
import stone from '../../icons/osm/stone.svg';
|
import stone from '../../icons/osm/stone.svg';
|
||||||
import spring from '../../icons/osm/spring.svg';
|
import spring from '../../icons/osm/spring.svg';
|
||||||
import fumarole from '../../icons/osm/eruption-svgrepo-com.svg';
|
import fumarole from '../../icons/osm/eruption-svgrepo-com.svg';
|
||||||
import parking from '../../icons/osm/parking.svg';
|
|
||||||
import bicycle_parking from '../../icons/osm/parking_bicycle.svg';
|
|
||||||
|
|
||||||
export const osmIcons = {
|
export const osmIcons = {
|
||||||
parking,
|
|
||||||
bicycle_parking,
|
|
||||||
bar,
|
bar,
|
||||||
fast_food,
|
fast_food,
|
||||||
food_court: fast_food,
|
food_court: fast_food,
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import { Fill, Text, Icon, Stroke, Style, Circle } from 'ol/style';
|
import { Fill, Text, Icon, Stroke, Style, Circle } from 'ol/style';
|
||||||
|
import startIcon from '../../icons/flag-start-b-svgrepo-com-green.svg';
|
||||||
|
import finishIcon from '../../icons/flag-finish-b-o-svgrepo-com-red.svg';
|
||||||
import wptIcon from '../../icons/location-pin-svgrepo-com-green.svg';
|
import wptIcon from '../../icons/location-pin-svgrepo-com-green.svg';
|
||||||
import houseIcon from '../../icons/house-svgrepo-com.svg';
|
import houseIcon from '../../icons/house-svgrepo-com.svg';
|
||||||
import houseFlatIcon from '../../icons/houseFlat-svgrepo-com.svg';
|
import houseFlatIcon from '../../icons/houseFlat-svgrepo-com.svg';
|
||||||
|
@ -8,41 +10,40 @@ import cheeseIcon from '../../icons/cheese-svgrepo-com.svg';
|
||||||
import trainIcon from '../../icons/train-svgrepo-com.svg';
|
import trainIcon from '../../icons/train-svgrepo-com.svg';
|
||||||
import picnicIcon from '../../icons/picnic-svgrepo-com.svg';
|
import picnicIcon from '../../icons/picnic-svgrepo-com.svg';
|
||||||
import caveIcon from '../../icons/cave-entrance-svgrepo-com.svg';
|
import caveIcon from '../../icons/cave-entrance-svgrepo-com.svg';
|
||||||
import hikerIcon from '../../icons/hiker-svgrepo-com.svg';
|
import leftArrowIcon from '../../icons/right-arrow-svgrepo-com.svg';
|
||||||
import cycleIcon from '../../icons/bicycle-man-svgrepo-com.svg';
|
|
||||||
import blackArrowheadPointingUp from '../../icons/black-arrowhead-pointing-up-svgrepo-com.svg';
|
import blackArrowheadPointingUp from '../../icons/black-arrowhead-pointing-up-svgrepo-com.svg';
|
||||||
import noteIcon from '../../icons/note-svgrepo-com.svg';
|
import wptIconSel from '../../icons/location-pin-svgrepo-com-red.svg';
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
import memoize from 'memoizee';
|
import memoize from 'memoizee';
|
||||||
import { getMap } from '../map';
|
import { getMap, getState } from '../map';
|
||||||
import { Point } from 'ol/geom';
|
import { Point } from 'ol/geom';
|
||||||
import { Coordinate } from 'ol/coordinate';
|
import { Coordinate } from 'ol/coordinate';
|
||||||
import { createDefaultStyle } from 'ol/style/Style';
|
import { createDefaultStyle } from 'ol/style/Style';
|
||||||
|
|
||||||
import osmIcons from './osm-icons';
|
import osmIcons, { highlight } from './osm-icons';
|
||||||
|
import { indexOf } from 'lodash';
|
||||||
import { getZoomInteger } from '../map/Map';
|
import { getZoomInteger } from '../map/Map';
|
||||||
import { isHighlightedTagType } from '../map-tile-provider/MapTileProvider';
|
import { isHighlighted } from '../map-tile-provider';
|
||||||
import { getCenter } from 'ol/extent';
|
|
||||||
import {
|
import {
|
||||||
getVectorTileFeatureType,
|
getAllPoiTypes,
|
||||||
getTagType,
|
getHighlightedTagValue,
|
||||||
} from '../overlays/overlay-definitions';
|
getTagValue,
|
||||||
import { Category } from '../wpt/WptEditDialog';
|
} from '../map-tile-provider/MapTileProvider';
|
||||||
import { mustBeDrawn } from '../drawing-selector';
|
import { getCenter } from 'ol/extent';
|
||||||
import { getTagValue } from '../../lib/tags/tags';
|
import { getVectorTileFeatureType } from '../overlays/overlay-definitions';
|
||||||
|
|
||||||
interface StyleParameters {
|
interface StyleParameters {
|
||||||
type: string;
|
type: string;
|
||||||
isSelected: boolean;
|
isSelected: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAllPoiTypes().forEach((type) => {
|
||||||
|
if (!Object.keys(osmIcons).includes(type)) {
|
||||||
|
console.warn({ caller: 'styles', message: 'missing icon', type });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const icons = {
|
const icons = {
|
||||||
note: {
|
|
||||||
src: noteIcon,
|
|
||||||
scale: 1 / 20,
|
|
||||||
opacity: 0.9,
|
|
||||||
anchor: [0.5, 1],
|
|
||||||
},
|
|
||||||
house: {
|
house: {
|
||||||
src: houseIcon,
|
src: houseIcon,
|
||||||
scale: 1 / 15,
|
scale: 1 / 15,
|
||||||
|
@ -115,6 +116,16 @@ const textFillSel = new Fill({
|
||||||
color: 'red',
|
color: 'red',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const trksegStroke = new Stroke({
|
||||||
|
color: [11, 16, 71, 0.8],
|
||||||
|
width: 3,
|
||||||
|
});
|
||||||
|
|
||||||
|
const trksegStrokeSel = new Stroke({
|
||||||
|
color: 'red',
|
||||||
|
width: 3,
|
||||||
|
});
|
||||||
|
|
||||||
const rteStroke = new Stroke({
|
const rteStroke = new Stroke({
|
||||||
color: [18, 71, 11, 0.8],
|
color: [18, 71, 11, 0.8],
|
||||||
width: 3,
|
width: 3,
|
||||||
|
@ -166,31 +177,21 @@ const memoizeOptions = {
|
||||||
const styles = {
|
const styles = {
|
||||||
wpt: {
|
wpt: {
|
||||||
getParameters: (feature: Feature) => {
|
getParameters: (feature: Feature) => {
|
||||||
if (!mustBeDrawn(feature)) return null;
|
const minZoom = feature.get('extensions')?.['dyo:minZoom'];
|
||||||
const extensions = feature.get('extensions');
|
|
||||||
const minZoom = extensions?.['dyo:minZoom'];
|
|
||||||
const category = extensions?.category;
|
|
||||||
return {
|
return {
|
||||||
isSelected: feature.get('isSelected') ?? false,
|
isSelected: feature.get('isSelected') ?? false,
|
||||||
text: feature.get('name'),
|
text: feature.get('name'),
|
||||||
customIcon:
|
customIcon: icons[feature.get('sym') as keyof typeof icons],
|
||||||
icons[feature.get('sym') as keyof typeof icons] ||
|
|
||||||
icons[category as keyof typeof icons],
|
|
||||||
thumbnailUrl:
|
|
||||||
category === Category.PICTURE ? extensions?.thumbnailUrl : undefined,
|
|
||||||
hidden: minZoom && getZoominteger() < minZoom,
|
hidden: minZoom && getZoominteger() < minZoom,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getStyle: memoize((params: any) => {
|
getStyle: memoize((params: any) => {
|
||||||
// console.log({ caller: 'getStyle', params });
|
// console.log({ caller: 'getStyle', params });
|
||||||
const { isSelected, text, customIcon, hidden, thumbnailUrl } = params;
|
const { isSelected, text, customIcon, hidden } = params;
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const thumbnailIcon = !!thumbnailUrl
|
const icon = customIcon ?? wptIconObj;
|
||||||
? { src: thumbnailUrl, scale: 1 / 2, anchor: [0.5, 0.5] }
|
|
||||||
: undefined;
|
|
||||||
const icon = customIcon ?? thumbnailIcon ?? wptIconObj;
|
|
||||||
return new Style({
|
return new Style({
|
||||||
image: new Icon(icon),
|
image: new Icon(icon),
|
||||||
text: new Text({
|
text: new Text({
|
||||||
|
@ -205,50 +206,18 @@ const styles = {
|
||||||
},
|
},
|
||||||
trkseg: {
|
trkseg: {
|
||||||
getParameters: (feature: Feature) => {
|
getParameters: (feature: Feature) => {
|
||||||
if (!mustBeDrawn(feature)) return null;
|
|
||||||
return {
|
return {
|
||||||
isSelected: feature.get('isSelected') ?? false,
|
isSelected: feature.get('isSelected') ?? false,
|
||||||
feature: getZoomInteger() >= 7 ? feature : undefined,
|
feature: getZoomInteger() >= 7 ? feature : undefined,
|
||||||
zoom: getZoomInteger() >= 7 ? Math.floor(getZoomInteger()) : undefined,
|
zoom: getZoomInteger() >= 7 ? Math.floor(getZoomInteger()) : undefined,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
ownStyles: {
|
|
||||||
normal: [
|
|
||||||
new Style({
|
|
||||||
stroke: new Stroke({
|
|
||||||
color: [44, 64, 255, 0.8],
|
|
||||||
width: 2,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
new Style({
|
|
||||||
stroke: new Stroke({
|
|
||||||
color: [44, 64, 255, 0.2],
|
|
||||||
width: 7,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
|
|
||||||
selected: [
|
|
||||||
new Style({
|
|
||||||
stroke: new Stroke({
|
|
||||||
color: [44, 64, 255, 0.8],
|
|
||||||
width: 2,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
new Style({
|
|
||||||
stroke: new Stroke({
|
|
||||||
color: [255, 0, 0, 0.4],
|
|
||||||
width: 7,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
getStyle: memoize((params: any) => {
|
getStyle: memoize((params: any) => {
|
||||||
// console.log({ caller: 'getStyle', params });
|
// console.log({ caller: 'getStyle', params });
|
||||||
const { isSelected, feature, zoom } = params;
|
const { isSelected, feature, zoom } = params;
|
||||||
let currentStyles: any = isSelected
|
const styles = [
|
||||||
? styles.trkseg.ownStyles.selected
|
new Style({ stroke: isSelected ? trksegStrokeSel : trksegStroke }),
|
||||||
: styles.trkseg.ownStyles.normal;
|
];
|
||||||
if (feature) {
|
if (feature) {
|
||||||
const map = getMap();
|
const map = getMap();
|
||||||
const geometry = feature.getGeometry();
|
const geometry = feature.getGeometry();
|
||||||
|
@ -268,7 +237,7 @@ const styles = {
|
||||||
const dx = end[0] - start[0];
|
const dx = end[0] - start[0];
|
||||||
const dy = end[1] - start[1];
|
const dy = end[1] - start[1];
|
||||||
const rotation = Math.atan2(dy, dx) - Math.PI / 2;
|
const rotation = Math.atan2(dy, dx) - Math.PI / 2;
|
||||||
currentStyles.push(
|
styles.push(
|
||||||
new Style({
|
new Style({
|
||||||
geometry: new Point(end),
|
geometry: new Point(end),
|
||||||
image: new Icon({
|
image: new Icon({
|
||||||
|
@ -285,38 +254,11 @@ const styles = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return currentStyles;
|
return styles;
|
||||||
}, memoizeOptions),
|
|
||||||
},
|
|
||||||
'trkseg-finish': {
|
|
||||||
getParameters: (feature: Feature) => {
|
|
||||||
if (!mustBeDrawn(feature)) return null;
|
|
||||||
const positions: Set<string> = feature.get('positions');
|
|
||||||
const tags: any = feature.get('tags') || {};
|
|
||||||
return {
|
|
||||||
isLast: positions.has('gpx-end') && positions.has('trk-end'),
|
|
||||||
locomotion: getTagValue(tags, 'locomotion') || 'hiking',
|
|
||||||
};
|
|
||||||
},
|
|
||||||
getStyle: memoize((params: any) => {
|
|
||||||
// console.log({ caller: 'getStyle', params });
|
|
||||||
const { isLast, locomotion } = params;
|
|
||||||
if (isLast) {
|
|
||||||
return new Style({
|
|
||||||
image: new Icon({
|
|
||||||
src: locomotion === 'cycling' ? cycleIcon : hikerIcon,
|
|
||||||
scale: 1 / 20,
|
|
||||||
opacity: 0.9,
|
|
||||||
anchor: [0.5, 0.5],
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}, memoizeOptions),
|
}, memoizeOptions),
|
||||||
},
|
},
|
||||||
rte: {
|
rte: {
|
||||||
getParameters: (feature: Feature) => {
|
getParameters: (feature: Feature) => {
|
||||||
if (!mustBeDrawn(feature)) return null;
|
|
||||||
return {
|
return {
|
||||||
isSelected: feature.get('isSelected') ?? false,
|
isSelected: feature.get('isSelected') ?? false,
|
||||||
};
|
};
|
||||||
|
@ -575,8 +517,8 @@ const styles = {
|
||||||
if (getZoomInteger() < 16) {
|
if (getZoomInteger() < 16) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const tagType = getTagType(feature);
|
const highlightedTagValue = getHighlightedTagValue(feature);
|
||||||
const isHighlightedFeature = isHighlightedTagType(tagType);
|
const isHighlightedFeature = !!highlightedTagValue;
|
||||||
if (
|
if (
|
||||||
(isHighlightedFeature && getZoomInteger() < 16) ||
|
(isHighlightedFeature && getZoomInteger() < 16) ||
|
||||||
(!isHighlightedFeature && getZoomInteger() < 18)
|
(!isHighlightedFeature && getZoomInteger() < 18)
|
||||||
|
@ -585,7 +527,9 @@ const styles = {
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
name: feature.get('name'),
|
name: feature.get('name'),
|
||||||
poiType: tagType,
|
poiType: isHighlightedFeature
|
||||||
|
? highlightedTagValue
|
||||||
|
: getTagValue(feature),
|
||||||
isHighlighted: isHighlightedFeature,
|
isHighlighted: isHighlightedFeature,
|
||||||
isTextHidden: getZoomInteger() < 19,
|
isTextHidden: getZoomInteger() < 19,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,355 +0,0 @@
|
||||||
import { useI18n } from '@solid-primitives/i18n';
|
|
||||||
import {
|
|
||||||
Typography,
|
|
||||||
Card,
|
|
||||||
CardContent,
|
|
||||||
CardActions,
|
|
||||||
Button,
|
|
||||||
Box,
|
|
||||||
LinearProgress,
|
|
||||||
CircularProgress,
|
|
||||||
} from '@suid/material';
|
|
||||||
import { Component, createEffect, createSignal, Show } from 'solid-js';
|
|
||||||
import { findStartTime } from '../../lib/gpx';
|
|
||||||
import GPX from '../../lib/gpx-parser-builder/src/gpx';
|
|
||||||
import dispatch from '../../workers/dispatcher-main';
|
|
||||||
import GpxChooser from '../gpx-chooser';
|
|
||||||
import { currentGpxId } from '../gpx-dialog';
|
|
||||||
import {
|
|
||||||
Filesystem as CapacitorFileSystem,
|
|
||||||
Encoding,
|
|
||||||
} from '@capacitor/filesystem';
|
|
||||||
import piexif from 'piexifjs';
|
|
||||||
import { getDate, getGps } from '../../lib/exif';
|
|
||||||
import { downsize } from '../../lib/image';
|
|
||||||
import { Coordinate } from 'ol/coordinate';
|
|
||||||
import WptEditDialog, { Category } from '../wpt/WptEditDialog';
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
file: File;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface StatsAndGpx {
|
|
||||||
gpx: Gpx;
|
|
||||||
stats: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Picture {
|
|
||||||
id: string;
|
|
||||||
date: string;
|
|
||||||
gpx: { Latitude: number; Longitude: number; Altitude: number };
|
|
||||||
thumbnailUrl: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const analyzeGpx = (gpx: Gpx | undefined) => {
|
|
||||||
if (gpx === undefined) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
const stats = {
|
|
||||||
creator: gpx.$.creator,
|
|
||||||
nbWpts: gpx.wpt ? gpx.wpt?.length : 0,
|
|
||||||
nbRtes: gpx.rte ? gpx.rte?.length : 0,
|
|
||||||
nbTrks: gpx.trk ? gpx.trk?.length : 0,
|
|
||||||
trkMaybeRte:
|
|
||||||
gpx.trk &&
|
|
||||||
gpx.trk[0].trkseg &&
|
|
||||||
gpx.trk[0].trkseg[0] &&
|
|
||||||
gpx.trk[0].trkseg[0].trkpt &&
|
|
||||||
!gpx.trk[0].trkseg[0].trkpt[0].time,
|
|
||||||
startTime: findStartTime(gpx),
|
|
||||||
};
|
|
||||||
|
|
||||||
return stats;
|
|
||||||
};
|
|
||||||
|
|
||||||
const ImportSingleFile: Component<Props> = ({ file: file }) => {
|
|
||||||
const [t] = useI18n();
|
|
||||||
const [statsAndGpx, setStatsAndGpx] = createSignal<StatsAndGpx>();
|
|
||||||
const [picture, setPicture] = createSignal<Picture>();
|
|
||||||
const [state, setState] = createSignal('init');
|
|
||||||
const [gpxId, setGpxId] = createSignal<string>('new');
|
|
||||||
|
|
||||||
const [open, setOpen] = createSignal<boolean>(false);
|
|
||||||
const [coordinate, setCoordinate] = createSignal<Coordinate>();
|
|
||||||
const [initialWpt, setInitialWpt] = createSignal({
|
|
||||||
$: { lat: 0, lon: 0 },
|
|
||||||
ele: undefined,
|
|
||||||
time: undefined,
|
|
||||||
magvar: undefined,
|
|
||||||
geoidheight: undefined,
|
|
||||||
name: undefined,
|
|
||||||
cmt: undefined,
|
|
||||||
desc: undefined,
|
|
||||||
src: undefined,
|
|
||||||
link: undefined,
|
|
||||||
sym: undefined,
|
|
||||||
type: undefined,
|
|
||||||
fix: undefined,
|
|
||||||
sat: undefined,
|
|
||||||
hdop: undefined,
|
|
||||||
vdop: undefined,
|
|
||||||
pdop: undefined,
|
|
||||||
ageofdgpsdata: undefined,
|
|
||||||
dgpsid: undefined,
|
|
||||||
extensions: {
|
|
||||||
address: undefined,
|
|
||||||
startTime: undefined,
|
|
||||||
endTime: undefined,
|
|
||||||
category: Category.PICTURE,
|
|
||||||
subCategory: undefined,
|
|
||||||
pictureId: '',
|
|
||||||
thumbnailUrl: '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
createEffect(() => {
|
|
||||||
setGpxId(currentGpxId());
|
|
||||||
});
|
|
||||||
|
|
||||||
const parseGpx = (content: string) => {
|
|
||||||
const gpx = GPX.parse(content);
|
|
||||||
console.log({
|
|
||||||
caller: 'ImportSingleFile / JSON',
|
|
||||||
gpxFile: file,
|
|
||||||
gpx,
|
|
||||||
gpxId: gpxId(),
|
|
||||||
});
|
|
||||||
setStatsAndGpx({ gpx, stats: analyzeGpx(gpx) });
|
|
||||||
};
|
|
||||||
|
|
||||||
if (typeof file === 'string') {
|
|
||||||
CapacitorFileSystem.requestPermissions().then((permissionStatus) => {
|
|
||||||
console.log({
|
|
||||||
caller: 'ImportSingleFile / content',
|
|
||||||
permissionStatus,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
CapacitorFileSystem.readFile({
|
|
||||||
path: file,
|
|
||||||
encoding: Encoding.UTF8,
|
|
||||||
}).then((content) => {
|
|
||||||
console.log({
|
|
||||||
caller: 'ImportSingleFile / content',
|
|
||||||
file,
|
|
||||||
content,
|
|
||||||
});
|
|
||||||
parseGpx(content.data);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const reader = new FileReader();
|
|
||||||
if (file.type === 'image/jpeg') {
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
reader.addEventListener(
|
|
||||||
'load',
|
|
||||||
async () => {
|
|
||||||
const imageUrl = reader.result;
|
|
||||||
const exifObj = piexif.load(imageUrl);
|
|
||||||
console.log({
|
|
||||||
caller: 'ImportSingleFile / Jpeg',
|
|
||||||
file,
|
|
||||||
type: file.type,
|
|
||||||
result: reader.result,
|
|
||||||
exifObj,
|
|
||||||
});
|
|
||||||
const id = exifObj.Exif[piexif.ExifIFD.ImageUniqueID];
|
|
||||||
const gps = getGps(exifObj);
|
|
||||||
const date = getDate(exifObj);
|
|
||||||
const [downsizedUrl, bigThumbnailUrl, thumbnailUrl] = await downsize(
|
|
||||||
reader.result,
|
|
||||||
[1024, 512, 128]
|
|
||||||
);
|
|
||||||
console.log({
|
|
||||||
caller: 'ImportSingleFile / Jpeg',
|
|
||||||
file,
|
|
||||||
id,
|
|
||||||
gps,
|
|
||||||
date,
|
|
||||||
type: file.type,
|
|
||||||
result: reader.result,
|
|
||||||
exifObj,
|
|
||||||
});
|
|
||||||
setPicture({
|
|
||||||
id,
|
|
||||||
gps,
|
|
||||||
date,
|
|
||||||
thumbnailUrl,
|
|
||||||
bigThumbnailUrl,
|
|
||||||
downsizedUrl,
|
|
||||||
});
|
|
||||||
setCoordinate([gps.longitude, gps.latitude]);
|
|
||||||
setInitialWpt({
|
|
||||||
...initialWpt(),
|
|
||||||
extensions: {
|
|
||||||
...initialWpt().extensions,
|
|
||||||
category: Category.PICTURE,
|
|
||||||
startTime: date.toISOString(),
|
|
||||||
endTime: date.toISOString(),
|
|
||||||
pictureId: id,
|
|
||||||
thumbnailUrl: thumbnailUrl,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
false
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// GPX
|
|
||||||
reader.readAsText(file);
|
|
||||||
reader.addEventListener(
|
|
||||||
'load',
|
|
||||||
async () => {
|
|
||||||
// this will then display a text gpxfile
|
|
||||||
console.log({
|
|
||||||
caller: 'ImportSingleFile / XML',
|
|
||||||
file,
|
|
||||||
type: file.type,
|
|
||||||
result: reader.result,
|
|
||||||
});
|
|
||||||
parseGpx(reader.result);
|
|
||||||
},
|
|
||||||
false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const doImport = async (forceImportAsRoutes: boolean = false) => {
|
|
||||||
setState('importing');
|
|
||||||
// console.log({ caller: 'GpxImport / JSON', file, gpx });
|
|
||||||
// if (gpx) {
|
|
||||||
// const startTime = new Date(findStartTime(gpx)!);
|
|
||||||
await dispatch({
|
|
||||||
action: 'pruneAndSaveImportedGpx',
|
|
||||||
params: {
|
|
||||||
id: gpxId(),
|
|
||||||
forceImportAsRoutes,
|
|
||||||
gpx: statsAndGpx()?.gpx,
|
|
||||||
tech:
|
|
||||||
typeof file === 'string'
|
|
||||||
? {
|
|
||||||
importDate: new Date().toISOString(),
|
|
||||||
uri: file,
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
lastModified: new Date(file.lastModified).toISOString(),
|
|
||||||
importDate: new Date().toISOString(),
|
|
||||||
name: file.name,
|
|
||||||
size: file.size,
|
|
||||||
type: file.type,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
console.log({
|
|
||||||
caller: 'GpxImport / JSON / done',
|
|
||||||
gpxFile: file,
|
|
||||||
gpx: statsAndGpx()?.gpx,
|
|
||||||
});
|
|
||||||
setState('done');
|
|
||||||
|
|
||||||
// } else {
|
|
||||||
// console.error({
|
|
||||||
// message: "can't parse GPX file",
|
|
||||||
// file,
|
|
||||||
// xml: fileReader.result,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// // TODO: error handling
|
|
||||||
// },
|
|
||||||
// false
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
};
|
|
||||||
|
|
||||||
const [selectedTrkTransform, setSelectedTrkTransform] = createSignal(
|
|
||||||
'importNonTimedTrksAsRtes'
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleTrkTransformChange = (event: any) => {
|
|
||||||
setSelectedTrkTransform(event.target.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const controlTrkTransformProps = (item: string) => ({
|
|
||||||
checked: selectedTrkTransform() === item,
|
|
||||||
onChange: handleTrkTransformChange,
|
|
||||||
value: item,
|
|
||||||
name: 'trkTransform',
|
|
||||||
label: t(item),
|
|
||||||
inputProps: { 'aria-label': item },
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Card raised>
|
|
||||||
<CardContent>
|
|
||||||
<Typography variant='h6'>
|
|
||||||
{t('file')}
|
|
||||||
{file.name}
|
|
||||||
</Typography>
|
|
||||||
</CardContent>
|
|
||||||
<CardContent>
|
|
||||||
<Show when={statsAndGpx() !== undefined}>
|
|
||||||
<Typography variant='body1'>
|
|
||||||
{t('gpxStats', statsAndGpx().stats)}{' '}
|
|
||||||
{statsAndGpx()?.stats.startTime
|
|
||||||
? t('gpxStartTime', statsAndGpx().stats)
|
|
||||||
: t('gpxNoStartTime')}
|
|
||||||
</Typography>
|
|
||||||
<Show when={statsAndGpx().stats.trkMaybeRte}>
|
|
||||||
<Typography variant='body1'>{t('trkMaybeRte')}</Typography>
|
|
||||||
</Show>
|
|
||||||
<Show when={state() === 'importing'}>
|
|
||||||
<LinearProgress />
|
|
||||||
</Show>
|
|
||||||
<CardActions>
|
|
||||||
<GpxChooser
|
|
||||||
gpxId={gpxId}
|
|
||||||
setGpxId={setGpxId}
|
|
||||||
disabled={state() != 'init'}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
variant='contained'
|
|
||||||
disabled={state() != 'init'}
|
|
||||||
onClick={() => doImport(false)}
|
|
||||||
>
|
|
||||||
{t('import')}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant='contained'
|
|
||||||
disabled={state() != 'init'}
|
|
||||||
onClick={() => doImport(true)}
|
|
||||||
>
|
|
||||||
{t('importAllTrksAsRtes')}
|
|
||||||
</Button>
|
|
||||||
</CardActions>
|
|
||||||
</Show>
|
|
||||||
<Show when={picture() !== undefined}>
|
|
||||||
<img src={picture()?.bigThumbnailUrl} />
|
|
||||||
<p>Id: {picture()?.id}</p>
|
|
||||||
<p>Date: {picture()?.date.toString()}</p>
|
|
||||||
<p>
|
|
||||||
Coordinates: {picture()?.gps.latitude}, {picture()?.gps.longitude}
|
|
||||||
</p>
|
|
||||||
<CardActions>
|
|
||||||
<Button
|
|
||||||
variant='contained'
|
|
||||||
disabled={state() != 'init'}
|
|
||||||
onClick={() => setOpen(true)}
|
|
||||||
>
|
|
||||||
{t('import')}
|
|
||||||
</Button>
|
|
||||||
</CardActions>
|
|
||||||
<Show when={open()}>
|
|
||||||
<WptEditDialog
|
|
||||||
open={open}
|
|
||||||
closeHandler={() => {
|
|
||||||
setOpen(false);
|
|
||||||
setState('imported');
|
|
||||||
}}
|
|
||||||
coordinate={coordinate}
|
|
||||||
initialWpt={initialWpt}
|
|
||||||
imageUrl={picture()?.downsizedUrl}
|
|
||||||
/>
|
|
||||||
</Show>
|
|
||||||
</Show>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ImportSingleFile;
|
|
|
@ -1 +0,0 @@
|
||||||
export { default, importUrls } from './Import';
|
|
|
@ -13,11 +13,14 @@ import Dialog from '../dialog';
|
||||||
import Tree from '../tree';
|
import Tree from '../tree';
|
||||||
import { GpxViewer } from '../gpx';
|
import { GpxViewer } from '../gpx';
|
||||||
import { Browser } from '@capacitor/browser';
|
import { Browser } from '@capacitor/browser';
|
||||||
import { isHighlightedTagType } from '../map-tile-provider/MapTileProvider';
|
import { isHighlighted } from '../map-tile-provider';
|
||||||
|
import {
|
||||||
|
getHighlightedTagValue,
|
||||||
|
getTagValue,
|
||||||
|
} from '../map-tile-provider/MapTileProvider';
|
||||||
import style from '../gpx/styles';
|
import style from '../gpx/styles';
|
||||||
import OsmFindAll from './OsmFindAll';
|
import OsmFindAll from './OsmFindAll';
|
||||||
import { toLonLat } from 'ol/proj';
|
import { toLonLat } from 'ol/proj';
|
||||||
import { getTagType } from '../overlays/overlay-definitions';
|
|
||||||
|
|
||||||
const Item = styled(Paper)(({ theme }) => ({
|
const Item = styled(Paper)(({ theme }) => ({
|
||||||
...theme.typography.body2,
|
...theme.typography.body2,
|
||||||
|
@ -213,11 +216,10 @@ const Infos: Component<{}> = (props) => {
|
||||||
<>
|
<>
|
||||||
{console.log({
|
{console.log({
|
||||||
caller: 'Infos / vector layer feature',
|
caller: 'Infos / vector layer feature',
|
||||||
|
highlightedTagValue:
|
||||||
isHighlighted: isHighlightedTagType(
|
getHighlightedTagValue(feature),
|
||||||
getTagType(feature)
|
isHighlighted: isHighlighted(feature),
|
||||||
),
|
tagValue: getTagValue(feature),
|
||||||
tagValue: getTagType(feature),
|
|
||||||
properties: feature.getProperties(),
|
properties: feature.getProperties(),
|
||||||
style: style(feature),
|
style: style(feature),
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -1,247 +0,0 @@
|
||||||
import {
|
|
||||||
Alert,
|
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
Modal,
|
|
||||||
TextField,
|
|
||||||
Typography,
|
|
||||||
} from '@suid/material';
|
|
||||||
import { Component, createEffect, createSignal, Show } from 'solid-js';
|
|
||||||
import { parseUserId } from '../../lib/user-id';
|
|
||||||
import dispatch from '../../workers/dispatcher-main';
|
|
||||||
import Dialog from '../dialog';
|
|
||||||
|
|
||||||
interface props {}
|
|
||||||
|
|
||||||
const [invitation, setInvitation] = createSignal<any>(false);
|
|
||||||
|
|
||||||
const fetchInvitation = () => {
|
|
||||||
fetch(invitation().url)
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((data) => {
|
|
||||||
setInvitation({ ...invitation(), data });
|
|
||||||
return invitation();
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
dispatch({
|
|
||||||
action: 'getAccount',
|
|
||||||
params: { id: invitation().data.id },
|
|
||||||
}).then((account) => {
|
|
||||||
console.log({ caller: 'Invitation / fetchInvitation', account });
|
|
||||||
setInvitation({ ...invitation(), existing: true });
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error({ caller: 'Invitation / fetchInvitation', error });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const openInvitation = (payload: string) => {
|
|
||||||
try {
|
|
||||||
const decoded = atob(payload);
|
|
||||||
const url = new URL(decoded);
|
|
||||||
setInvitation({ url });
|
|
||||||
fetchInvitation();
|
|
||||||
} catch {
|
|
||||||
console.warn({
|
|
||||||
caller: 'Invitation / searchInvitationInIntent',
|
|
||||||
payload,
|
|
||||||
message: 'Query is not a base64 encoded URL',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const searchInvitation = () => {
|
|
||||||
const hash = location.hash;
|
|
||||||
console.log({ caller: 'Invitation / searchInvitation', hash });
|
|
||||||
|
|
||||||
if (hash.length > 1) {
|
|
||||||
try {
|
|
||||||
const payload = hash.slice(1);
|
|
||||||
const decoded = atob(payload);
|
|
||||||
const url = new URL(decoded);
|
|
||||||
setInvitation({ url });
|
|
||||||
fetchInvitation();
|
|
||||||
} catch {
|
|
||||||
console.warn({
|
|
||||||
caller: 'Invitation / searchInvitation',
|
|
||||||
hash,
|
|
||||||
message: 'Hash is not a base64 encoded URL',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const Invitation: Component<props> = (props) => {
|
|
||||||
createEffect(() => {
|
|
||||||
console.log({
|
|
||||||
caller: 'Invitation / createEffect',
|
|
||||||
invitation: invitation(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const closeHandler = () => {};
|
|
||||||
const submitHandler = async () => {
|
|
||||||
try {
|
|
||||||
const response = await fetch(
|
|
||||||
`${invitation().url.href}/${invitation().code}`
|
|
||||||
);
|
|
||||||
const codeData = await response.json();
|
|
||||||
setInvitation({
|
|
||||||
...invitation(),
|
|
||||||
codeData,
|
|
||||||
failure: codeData.response !== 'OK',
|
|
||||||
success: codeData.response === 'OK',
|
|
||||||
});
|
|
||||||
const user = invitation().codeData.user;
|
|
||||||
const id = user._id;
|
|
||||||
const account = {
|
|
||||||
id,
|
|
||||||
localDb: id,
|
|
||||||
name: id,
|
|
||||||
remoteDbServer: user.database,
|
|
||||||
remoteDbUser: user.username,
|
|
||||||
remoteDbPassword: user.password,
|
|
||||||
mail: user.mail,
|
|
||||||
};
|
|
||||||
dispatch({ action: 'putAccount', params: { id, account } });
|
|
||||||
const settings: any = await dispatch({ action: 'getSettings' });
|
|
||||||
dispatch({
|
|
||||||
action: 'putSettings',
|
|
||||||
params: { settings: { ...settings, currentAccountId: id } },
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
setInvitation({
|
|
||||||
...invitation(),
|
|
||||||
failure: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const codeChangeHandler = (event: any) => {
|
|
||||||
setInvitation({ ...invitation(), code: event.target.value });
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleModalFailureClose = () => {
|
|
||||||
setInvitation({ ...invitation(), failure: undefined, existing: undefined });
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCloseSuccess = () => {
|
|
||||||
setInvitation(false);
|
|
||||||
location.reload();
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Show when={!!invitation() && !!invitation().data}>
|
|
||||||
<Dialog
|
|
||||||
open={!!invitation() && !!invitation().data}
|
|
||||||
fullScreen={false}
|
|
||||||
closeHandler={closeHandler}
|
|
||||||
title='Invitation'
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
component='form'
|
|
||||||
sx={{
|
|
||||||
width: '100%',
|
|
||||||
'& .MuiTextField-root': { m: 1, width: '100%' },
|
|
||||||
paddingTop: '5px',
|
|
||||||
}}
|
|
||||||
noValidate
|
|
||||||
autoComplete='off'
|
|
||||||
>
|
|
||||||
<p>
|
|
||||||
Pour configurer cette application en tant que "
|
|
||||||
{invitation().data.id}
|
|
||||||
", copier le code qui vous a été envoyé par mail à l'adresse "
|
|
||||||
{invitation().data.mail}" :{' '}
|
|
||||||
</p>
|
|
||||||
<TextField
|
|
||||||
required
|
|
||||||
label='Code'
|
|
||||||
type='number'
|
|
||||||
onChange={codeChangeHandler}
|
|
||||||
/>
|
|
||||||
<Button variant='contained' onClick={submitHandler}>
|
|
||||||
OK
|
|
||||||
</Button>
|
|
||||||
<Button variant='outlined' onClick={fetchInvitation}>
|
|
||||||
Renvoyer le code
|
|
||||||
</Button>
|
|
||||||
<Button variant='outlined' color='error' onClick={handleCloseSuccess}>
|
|
||||||
Annuler
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
</Dialog>
|
|
||||||
<Modal
|
|
||||||
open={!!invitation().failure}
|
|
||||||
onClose={handleModalFailureClose}
|
|
||||||
aria-labelledby='modal-modal-title'
|
|
||||||
aria-describedby='modal-modal-description'
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
position: 'absolute',
|
|
||||||
top: '50%',
|
|
||||||
left: '50%',
|
|
||||||
transform: 'translate(-50%, -50%)',
|
|
||||||
width: 400,
|
|
||||||
border: '2px solid #000',
|
|
||||||
boxShadow: '24px',
|
|
||||||
p: 4,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Alert severity='error'>Le code est erroné !</Alert>
|
|
||||||
</Box>
|
|
||||||
</Modal>
|
|
||||||
<Modal
|
|
||||||
open={!!invitation().success}
|
|
||||||
onClose={handleCloseSuccess}
|
|
||||||
aria-labelledby='modal-modal-title'
|
|
||||||
aria-describedby='modal-modal-description'
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
position: 'absolute',
|
|
||||||
top: '50%',
|
|
||||||
left: '50%',
|
|
||||||
transform: 'translate(-50%, -50%)',
|
|
||||||
width: 400,
|
|
||||||
border: '2px solid #000',
|
|
||||||
boxShadow: '24px',
|
|
||||||
p: 4,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Alert severity='success'>C'est tout bon !</Alert>
|
|
||||||
</Box>
|
|
||||||
</Modal>
|
|
||||||
<Modal
|
|
||||||
open={!!invitation().existing}
|
|
||||||
onClose={handleModalFailureClose}
|
|
||||||
aria-labelledby='modal-modal-title'
|
|
||||||
aria-describedby='modal-modal-description'
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
position: 'absolute',
|
|
||||||
top: '50%',
|
|
||||||
left: '50%',
|
|
||||||
transform: 'translate(-50%, -50%)',
|
|
||||||
width: 400,
|
|
||||||
border: '2px solid #000',
|
|
||||||
boxShadow: '24px',
|
|
||||||
p: 4,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Alert severity='info'>
|
|
||||||
Ce compte est déjà configuré, vous pouvez soit continuer et le
|
|
||||||
reconfigurer soit abandonner cette action et ne pas tenir compte du
|
|
||||||
message qui vous a été envoyé.
|
|
||||||
</Alert>
|
|
||||||
</Box>
|
|
||||||
</Modal>
|
|
||||||
</Show>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Invitation;
|
|
|
@ -1 +0,0 @@
|
||||||
export { default, searchInvitation } from './Invitation';
|
|
|
@ -1,10 +1,15 @@
|
||||||
import OSM from 'ol/source/OSM';
|
import OSM from 'ol/source/OSM';
|
||||||
import XYZ from 'ol/source/XYZ';
|
import XYZ from 'ol/source/XYZ';
|
||||||
import { Component, createEffect, createSignal, For, Show } from 'solid-js';
|
import { Component, createEffect, createSignal, For, Show } from 'solid-js';
|
||||||
import { useI18n } from '@solid-primitives/i18n';
|
import {
|
||||||
|
I18nContext,
|
||||||
|
createI18nContext,
|
||||||
|
useI18n,
|
||||||
|
} from '@solid-primitives/i18n';
|
||||||
|
|
||||||
import style from './MapTileProvider.module.css';
|
import style from './MapTileProvider.module.css';
|
||||||
import LayersIcon from '@suid/icons-material/Layers';
|
import LayersIcon from '@suid/icons-material/Layers';
|
||||||
|
import CloseIcon from '@suid/icons-material/Close';
|
||||||
import {
|
import {
|
||||||
FormControlLabel,
|
FormControlLabel,
|
||||||
IconButton,
|
IconButton,
|
||||||
|
@ -20,13 +25,9 @@ import getUri from '../../lib/ids';
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
overlayCategories,
|
||||||
overlayDefinitions,
|
overlayDefinitions,
|
||||||
osmTags,
|
|
||||||
OsmTag,
|
|
||||||
getTagType,
|
|
||||||
} from '../overlays/overlay-definitions';
|
} from '../overlays/overlay-definitions';
|
||||||
import { cloneDeep } from 'lodash';
|
|
||||||
import DrawingSelector from '../drawing-selector/DrawingSelector';
|
|
||||||
|
|
||||||
const id = getUri('overlays', undefined);
|
const id = getUri('overlays', undefined);
|
||||||
|
|
||||||
|
@ -112,18 +113,76 @@ type Overlay = {
|
||||||
};
|
};
|
||||||
type Overlays = Record<string, Overlay>;
|
type Overlays = Record<string, Overlay>;
|
||||||
|
|
||||||
const defaultOverlayContent = {
|
|
||||||
selected: false,
|
|
||||||
highlighted: {
|
|
||||||
none: [],
|
|
||||||
},
|
|
||||||
hidden: { none: [] },
|
|
||||||
};
|
|
||||||
|
|
||||||
const defaultOverlays: Overlays = {
|
const defaultOverlays: Overlays = {
|
||||||
none: { selected: true, highlighted: { none: [] }, hidden: {} },
|
none: { selected: true, highlighted: { none: [] }, hidden: {} },
|
||||||
|
hiking: {
|
||||||
|
selected: false,
|
||||||
|
highlighted: {
|
||||||
|
none: [],
|
||||||
|
},
|
||||||
|
hidden: { none: [] },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// type OverlayDefinition = Record<string, FeatureTypes>;
|
||||||
|
// type OverlayDefinitions = Record<string, OverlayDefinition>;
|
||||||
|
|
||||||
|
// export const overlayDefinitions: OverlayDefinitions = {
|
||||||
|
// none: {},
|
||||||
|
// hiking: {
|
||||||
|
// none: {},
|
||||||
|
// sleeping: {
|
||||||
|
// tourism: [
|
||||||
|
// 'hotel',
|
||||||
|
// 'alpine_hut',
|
||||||
|
// 'apartment',
|
||||||
|
// 'camp_site',
|
||||||
|
// 'chalet',
|
||||||
|
// 'guest_house',
|
||||||
|
// 'hostel',
|
||||||
|
// 'motel',
|
||||||
|
// 'wilderness_hut',
|
||||||
|
// ],
|
||||||
|
// },
|
||||||
|
// drinking: {
|
||||||
|
// amenity: ['bar', 'cafe', 'pub', 'drinking_water', 'water_point'],
|
||||||
|
// natural: ['spring'],
|
||||||
|
// },
|
||||||
|
// eating: {
|
||||||
|
// amenity: ['fast_food', 'pub', 'restaurant'],
|
||||||
|
// shop: [
|
||||||
|
// 'bakery',
|
||||||
|
// 'butcher',
|
||||||
|
// 'cheese',
|
||||||
|
// 'chocolate',
|
||||||
|
// 'convenience',
|
||||||
|
// 'dairy',
|
||||||
|
// 'farm',
|
||||||
|
// 'greengrocer',
|
||||||
|
// 'health_food',
|
||||||
|
// 'pastry',
|
||||||
|
// 'seafood',
|
||||||
|
// 'department_store',
|
||||||
|
// 'supermarket',
|
||||||
|
// ],
|
||||||
|
// },
|
||||||
|
// health: {
|
||||||
|
// amenity: ['doctors', 'hospital', 'pharmacy'],
|
||||||
|
// },
|
||||||
|
// security: {
|
||||||
|
// amenity: ['police', 'fire_station'],
|
||||||
|
// },
|
||||||
|
// dayToday: {
|
||||||
|
// amenity: ['waste_basket', 'waste_disposal'],
|
||||||
|
// shop: ['laundry'],
|
||||||
|
// },
|
||||||
|
// naturalSites: {
|
||||||
|
// tourism: ['viewpoint'],
|
||||||
|
// natural: '*',
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// };
|
||||||
|
|
||||||
const getOverlays = createCachedSignal({
|
const getOverlays = createCachedSignal({
|
||||||
id,
|
id,
|
||||||
method: 'getOverlays',
|
method: 'getOverlays',
|
||||||
|
@ -138,24 +197,153 @@ const currentOverlayKey = () =>
|
||||||
const currentOverlay = () =>
|
const currentOverlay = () =>
|
||||||
getOverlays() ? getOverlays()[currentOverlayKey()] : {};
|
getOverlays() ? getOverlays()[currentOverlayKey()] : {};
|
||||||
|
|
||||||
const overlayDefinitionsPlusNone = { none: {}, ...overlayDefinitions };
|
const overlayCategoriesPlusNone = { none: [], ...overlayCategories };
|
||||||
|
|
||||||
export const currentCategory = () =>
|
export const currentCategory = () =>
|
||||||
Object.keys(
|
currentOverlayKey() === 'none'
|
||||||
currentOverlayKey() === 'none'
|
? []
|
||||||
? {}
|
: ['none', ...overlayCategoriesPlusNone[currentOverlayKey()]];
|
||||||
: { none: [], ...overlayDefinitionsPlusNone[currentOverlayKey()] }
|
|
||||||
);
|
|
||||||
|
|
||||||
const currentOverlayHighlightedKey = () =>
|
const currentOverlayHighlightedKey = () =>
|
||||||
currentOverlay() && currentOverlay().highlighted
|
currentOverlay() && currentOverlay().highlighted
|
||||||
? currentOverlay().highlighted
|
? currentOverlay().highlighted
|
||||||
: 'none';
|
: 'none';
|
||||||
|
|
||||||
export const isHighlightedTagType = (tagType: string) => {
|
export const currentOverlayHighlightedDefinition = () =>
|
||||||
const currentOverlayHighlightedDefinition: string[] =
|
currentCategory()[currentOverlayHighlightedKey()];
|
||||||
overlayDefinitions[currentOverlayKey()][currentOverlayHighlightedKey()];
|
|
||||||
return currentOverlayHighlightedDefinition.includes(tagType);
|
export const getAllPoiTypes = () => {
|
||||||
|
let result = new Set();
|
||||||
|
Object.keys(overlayDefinitions).forEach((tagName) => {
|
||||||
|
const tag = overlayDefinitions[tagName];
|
||||||
|
result = new Set([...result, ...Object.keys(tag)]);
|
||||||
|
});
|
||||||
|
return [...result];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const highlightedTags = () => {
|
||||||
|
let result = {};
|
||||||
|
Object.keys(overlayDefinitions).forEach((tagName) => {
|
||||||
|
let tagValues = [];
|
||||||
|
const tag = overlayDefinitions[tagName];
|
||||||
|
Object.keys(tag).forEach((tagValue) => {
|
||||||
|
const catDef = tag[tagValue];
|
||||||
|
Object.keys(catDef).forEach((catName) => {
|
||||||
|
if (catName === currentOverlayKey()) {
|
||||||
|
const catValue = catDef[catName];
|
||||||
|
if (catValue[currentOverlay()?.highlighted]) {
|
||||||
|
tagValues = [...tagValues, tagValue];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (tagValues.length > 0) {
|
||||||
|
result[tagName] = tagValues;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.log({
|
||||||
|
// caller: 'MapTileProviders / highlightedTags',
|
||||||
|
// result,
|
||||||
|
// currentOverlayKey: currentOverlayKey(),
|
||||||
|
// currentOverlay: currentOverlay(),
|
||||||
|
// });
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
// createEffect(() => {
|
||||||
|
// highlightedTags = {};
|
||||||
|
// Object.keys(overlayDefinitions).forEach((tagName) => {
|
||||||
|
// let tagValues = [];
|
||||||
|
// const tag = overlayDefinitions[tagName];
|
||||||
|
// Object.keys(tag).forEach((tagValue) => {
|
||||||
|
// const catDef = tag[tagValue];
|
||||||
|
// Object.keys(catDef).forEach((catName) => {
|
||||||
|
// if (catName === currentOverlayKey()) {
|
||||||
|
// const catValue = catDef[catName];
|
||||||
|
// if (catValue[currentOverlay()?.highlighted]) {
|
||||||
|
// tagValues = [...tagValues, tagValue];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// if (tagValues.length > 0) {
|
||||||
|
// highlightedTags[tagName] = tagValues;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// console.log({
|
||||||
|
// caller: 'MapTileProviders / createEffect',
|
||||||
|
// highlightedTags,
|
||||||
|
// currentOverlayKey: currentOverlayKey(),
|
||||||
|
// currentOverlay: currentOverlay(),
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
export const getHighlightedTagValue = (feature: Feature) => {
|
||||||
|
let result = false;
|
||||||
|
|
||||||
|
Object.keys(highlightedTags()).every((tagName) => {
|
||||||
|
const value = feature.get(tagName);
|
||||||
|
const highlightedValues = highlightedTags()[tagName];
|
||||||
|
// console.log({
|
||||||
|
// caller: 'MapTileProviders / highlightedTag / found',
|
||||||
|
// feature,
|
||||||
|
// feature_values: feature.values_,
|
||||||
|
// highlightedTags,
|
||||||
|
// tagName,
|
||||||
|
// tag_value: value,
|
||||||
|
// highlightedValues,
|
||||||
|
// });
|
||||||
|
|
||||||
|
if (value !== undefined && highlightedValues.includes(value)) {
|
||||||
|
result = value;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
// console.log({
|
||||||
|
// caller: 'MapTileProviders / highlightedTag / result',
|
||||||
|
// feature,
|
||||||
|
// feature_values: feature.values_,
|
||||||
|
// highlightedTags,
|
||||||
|
// result,
|
||||||
|
// });
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const isHighlighted = (feature: Feature) => {
|
||||||
|
return !!getHighlightedTagValue(feature);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getTagValue = (feature: Feature) => {
|
||||||
|
let result = false;
|
||||||
|
Object.keys(overlayDefinitions).every((tagName) => {
|
||||||
|
const value = feature.get(tagName);
|
||||||
|
const tagValues = overlayDefinitions[tagName];
|
||||||
|
|
||||||
|
if (value !== undefined && Object.keys(tagValues).includes(value)) {
|
||||||
|
// console.log({
|
||||||
|
// caller: 'MapTileProviders / tagValue / found',
|
||||||
|
// feature,
|
||||||
|
// feature_values: feature.values_,
|
||||||
|
// highlightedTags,
|
||||||
|
// tagName,
|
||||||
|
// tag_value: value,
|
||||||
|
// highlightedValues,
|
||||||
|
// });
|
||||||
|
result = value;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
// console.log({
|
||||||
|
// caller: 'MapTileProviders / isHighlighted / false',
|
||||||
|
// feature,
|
||||||
|
// feature_values: feature.values_,
|
||||||
|
// highlightedTags,
|
||||||
|
// });
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const MapTilesProvider: Component<{}> = (props) => {
|
const MapTilesProvider: Component<{}> = (props) => {
|
||||||
|
@ -192,14 +380,6 @@ const MapTilesProvider: Component<{}> = (props) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const getOverlaysAddingSelectedIfMissing = (key: string) => {
|
|
||||||
const overlays = getOverlays();
|
|
||||||
if (!Object.keys(overlays).includes(key)) {
|
|
||||||
overlays[key] = cloneDeep(defaultOverlayContent);
|
|
||||||
}
|
|
||||||
return overlays;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleOverlayChange = (ev: any) => {
|
const handleOverlayChange = (ev: any) => {
|
||||||
const value = ev.target.value;
|
const value = ev.target.value;
|
||||||
console.log({
|
console.log({
|
||||||
|
@ -207,7 +387,7 @@ const MapTilesProvider: Component<{}> = (props) => {
|
||||||
ev,
|
ev,
|
||||||
value,
|
value,
|
||||||
});
|
});
|
||||||
const newOverlays = getOverlaysAddingSelectedIfMissing(value);
|
const newOverlays = getOverlays();
|
||||||
Object.keys(newOverlays).forEach((key) => {
|
Object.keys(newOverlays).forEach((key) => {
|
||||||
newOverlays[key].selected = key === value;
|
newOverlays[key].selected = key === value;
|
||||||
});
|
});
|
||||||
|
@ -244,7 +424,6 @@ const MapTilesProvider: Component<{}> = (props) => {
|
||||||
open={open()}
|
open={open()}
|
||||||
title={t('chooseYourMap')}
|
title={t('chooseYourMap')}
|
||||||
>
|
>
|
||||||
<DrawingSelector/>
|
|
||||||
<Tree
|
<Tree
|
||||||
title={t('overlay')}
|
title={t('overlay')}
|
||||||
content={
|
content={
|
||||||
|
@ -253,7 +432,7 @@ const MapTilesProvider: Component<{}> = (props) => {
|
||||||
defaultValue={currentOverlayKey()}
|
defaultValue={currentOverlayKey()}
|
||||||
onChange={handleOverlayChange}
|
onChange={handleOverlayChange}
|
||||||
>
|
>
|
||||||
<For each={Object.keys(overlayDefinitionsPlusNone)}>
|
<For each={Object.keys(overlayCategoriesPlusNone)}>
|
||||||
{(p: string) => (
|
{(p: string) => (
|
||||||
<FormControlLabel value={p} control={<Radio />} label={p} />
|
<FormControlLabel value={p} control={<Radio />} label={p} />
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -2,5 +2,6 @@ export {
|
||||||
default,
|
default,
|
||||||
mapTileProviders,
|
mapTileProviders,
|
||||||
currentCategory as currentOverlayDefinition,
|
currentCategory as currentOverlayDefinition,
|
||||||
isHighlightedTagType,
|
currentOverlayHighlightedDefinition,
|
||||||
|
isHighlighted,
|
||||||
} from './MapTileProvider';
|
} from './MapTileProvider';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Component, createEffect, createSignal, onMount } from 'solid-js';
|
import { Component, createEffect, createSignal, onMount } from 'solid-js';
|
||||||
import { useParams, useNavigate } from '@solidjs/router';
|
import { useParams, useNavigate, useLocation } from '@solidjs/router';
|
||||||
import OlMap from 'ol/Map';
|
import OlMap from 'ol/Map';
|
||||||
import View from 'ol/View';
|
import View from 'ol/View';
|
||||||
import TileLayer from 'ol/layer/Tile';
|
import TileLayer from 'ol/layer/Tile';
|
||||||
|
@ -10,22 +10,22 @@ import Attribution from 'ol/control/Attribution';
|
||||||
import Rotate from 'ol/control/Rotate';
|
import Rotate from 'ol/control/Rotate';
|
||||||
import ScaleLine from 'ol/control/ScaleLine';
|
import ScaleLine from 'ol/control/ScaleLine';
|
||||||
import Control from 'ol/control/Control';
|
import Control from 'ol/control/Control';
|
||||||
import Zoom from 'ol/control/Zoom';
|
|
||||||
import { fromLonLat, toLonLat } from 'ol/proj';
|
import { fromLonLat, toLonLat } from 'ol/proj';
|
||||||
import DragRotate from 'ol/interaction/DragRotate';
|
import DragRotate from 'ol/interaction/DragRotate';
|
||||||
|
|
||||||
import 'ol/ol.css';
|
import 'ol/ol.css';
|
||||||
import './Map.css';
|
import './Map.css';
|
||||||
import { Collection } from 'ol';
|
import { Collection, Overlay } from 'ol';
|
||||||
import { Point } from 'ol/geom';
|
import { Point } from 'ol/geom';
|
||||||
import { Style, Icon } from 'ol/style';
|
import { Style, Icon } from 'ol/style';
|
||||||
import GetLocation, { getCurrentLocation } from '../get-location';
|
import GetLocation, { getCurrentLocation } from '../get-location';
|
||||||
import ShowLocationIcon from '../get-location/ShowLocationIcon.svg';
|
import ShowLocationIcon from '../get-location/ShowLocationIcon.svg';
|
||||||
import { Back, Forward } from '../back-forward';
|
import { Back, Forward } from '../back-forward';
|
||||||
import GpxImport, { importUrls } from '../import';
|
import GpxImport, { importUrls } from '../gpx-import';
|
||||||
import AllGpxes from '../all-gpxes';
|
import AllGpxes from '../all-gpxes';
|
||||||
import MapTileProvider, { mapTileProviders } from '../map-tile-provider';
|
import MapTileProvider, { mapTileProviders } from '../map-tile-provider';
|
||||||
import Interaction from 'ol/interaction/Interaction';
|
import Interaction from 'ol/interaction/Interaction';
|
||||||
|
import DoubleClickZoom from 'ol/interaction/DoubleClickZoom';
|
||||||
import DragPan from 'ol/interaction/DragPan';
|
import DragPan from 'ol/interaction/DragPan';
|
||||||
import PinchRotate from 'ol/interaction/PinchRotate';
|
import PinchRotate from 'ol/interaction/PinchRotate';
|
||||||
import PinchZoom from 'ol/interaction/PinchZoom';
|
import PinchZoom from 'ol/interaction/PinchZoom';
|
||||||
|
@ -40,13 +40,9 @@ import dispatch from '../../workers/dispatcher-main';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
|
|
||||||
import { AndroidFullScreen } from '@awesome-cordova-plugins/android-full-screen';
|
import { AndroidFullScreen } from '@awesome-cordova-plugins/android-full-screen';
|
||||||
|
import Account from '../account';
|
||||||
import { Overlays } from '../overlays/Overlays';
|
import { Overlays } from '../overlays/Overlays';
|
||||||
import Finder, { findLocation } from '../finder';
|
import Finder, { findLocation } from '../finder';
|
||||||
import Note from '../note';
|
|
||||||
import Invitation, { searchInvitation } from '../invitation';
|
|
||||||
import Updater from '../updater';
|
|
||||||
import SystemDrawer from '../system-drawer';
|
|
||||||
import { receiveIntent } from '../../lib/intent-receivers';
|
|
||||||
|
|
||||||
const [getState, setState] = createSignal({
|
const [getState, setState] = createSignal({
|
||||||
lon: 0,
|
lon: 0,
|
||||||
|
@ -64,11 +60,15 @@ const [getMap, setMap] = createSignal<OlMap | null>(null);
|
||||||
|
|
||||||
export { getMap };
|
export { getMap };
|
||||||
|
|
||||||
|
const useHash = () => useLocation().hash;
|
||||||
|
|
||||||
const Map: Component = () => {
|
const Map: Component = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
|
|
||||||
searchInvitation();
|
createEffect(() => {
|
||||||
|
console.log({ caller: 'Map / createEffect', hash: useHash() });
|
||||||
|
});
|
||||||
|
|
||||||
// See https://stackoverflow.com/questions/71288670/how-to-make-fullscreen-ionic-capacitor-app
|
// See https://stackoverflow.com/questions/71288670/how-to-make-fullscreen-ionic-capacitor-app
|
||||||
AndroidFullScreen.isImmersiveModeSupported()
|
AndroidFullScreen.isImmersiveModeSupported()
|
||||||
|
@ -92,8 +92,15 @@ const Map: Component = () => {
|
||||||
);
|
);
|
||||||
window.plugins.intentShim.onIntent(function (intent: any) {
|
window.plugins.intentShim.onIntent(function (intent: any) {
|
||||||
console.log({ caller: 'Intent receiver', intent });
|
console.log({ caller: 'Intent receiver', intent });
|
||||||
if (receiveIntent(intent, navigate)) {
|
if (intent.action === 'android.intent.action.VIEW') {
|
||||||
return;
|
const url = new URL(intent.data);
|
||||||
|
const q = url.search;
|
||||||
|
const [, lat, lon] = q.match(/q=([0-9.-]+),([0-9.-]+)/);
|
||||||
|
console.log({ caller: 'Intent receiver', intent, url, lat, lon });
|
||||||
|
findLocation(navigate, [lon, lat]);
|
||||||
|
} else if (intent.action === 'android.intent.action.SEND') {
|
||||||
|
const uri = intent.extras['android.intent.extra.STREAM'];
|
||||||
|
importUrls([uri]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,33 +111,6 @@ const Map: Component = () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const dropHandler = (event: any) => {
|
|
||||||
event.preventDefault();
|
|
||||||
console.log({
|
|
||||||
caller: 'Map / dropHandler',
|
|
||||||
event,
|
|
||||||
files: event.dataTransfer.files,
|
|
||||||
});
|
|
||||||
importUrls(event.dataTransfer.files);
|
|
||||||
};
|
|
||||||
|
|
||||||
const dragEnterHandler = (event: any) => {
|
|
||||||
event.preventDefault();
|
|
||||||
console.log({ caller: 'Map / dragEnterHandler', event });
|
|
||||||
};
|
|
||||||
|
|
||||||
const dragOverHandler = (event: any) => {
|
|
||||||
event.preventDefault();
|
|
||||||
console.log({ caller: 'Map / dragOverHandler', event });
|
|
||||||
};
|
|
||||||
|
|
||||||
// const dragStartHandler = (event: any) => {
|
|
||||||
// event.preventDefault();
|
|
||||||
// event.dataTransfer.effectAllowed = 'all';
|
|
||||||
// event.dataTransfer.dropEffect = 'move';
|
|
||||||
// console.log({ caller: 'Map / dragStartHandler', event });
|
|
||||||
// };
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
params.lat === '0' &&
|
params.lat === '0' &&
|
||||||
params.lon === '0' &&
|
params.lon === '0' &&
|
||||||
|
@ -161,7 +141,6 @@ const Map: Component = () => {
|
||||||
params: {
|
params: {
|
||||||
...params,
|
...params,
|
||||||
},
|
},
|
||||||
lastCommit: import.meta.env.VITE_GIT_COMMIT_HASH,
|
|
||||||
});
|
});
|
||||||
setState({
|
setState({
|
||||||
provider: params.provider,
|
provider: params.provider,
|
||||||
|
@ -273,16 +252,6 @@ const Map: Component = () => {
|
||||||
// vectorTile: clusterableVectorTileSource.getProjection(),
|
// vectorTile: clusterableVectorTileSource.getProjection(),
|
||||||
// });
|
// });
|
||||||
|
|
||||||
let controls = [
|
|
||||||
new Attribution({ collapsible: true }),
|
|
||||||
new Rotate(),
|
|
||||||
new ScaleLine({ bar: true }),
|
|
||||||
];
|
|
||||||
|
|
||||||
if (window.Capacitor.platform === 'web') {
|
|
||||||
controls.push(new Zoom());
|
|
||||||
}
|
|
||||||
|
|
||||||
const olMap = new OlMap({
|
const olMap = new OlMap({
|
||||||
view: new View({
|
view: new View({
|
||||||
center: fromLonLat([+getState().lon, +getState().lat]),
|
center: fromLonLat([+getState().lon, +getState().lat]),
|
||||||
|
@ -291,11 +260,15 @@ const Map: Component = () => {
|
||||||
}),
|
}),
|
||||||
layers: [tileLayer, vectorLayer],
|
layers: [tileLayer, vectorLayer],
|
||||||
target: target,
|
target: target,
|
||||||
controls: new Collection<Control>(controls),
|
controls: new Collection<Control>([
|
||||||
|
new Attribution({ collapsible: true }),
|
||||||
|
new Rotate(),
|
||||||
|
new ScaleLine({ bar: true }),
|
||||||
|
]),
|
||||||
moveTolerance: 10,
|
moveTolerance: 10,
|
||||||
interactions: new Collection<Interaction>([
|
interactions: new Collection<Interaction>([
|
||||||
new DragRotate(),
|
new DragRotate(),
|
||||||
// new DoubleClickZoom(),
|
new DoubleClickZoom(),
|
||||||
new DragPan(),
|
new DragPan(),
|
||||||
new PinchRotate(),
|
new PinchRotate(),
|
||||||
new PinchZoom(),
|
new PinchZoom(),
|
||||||
|
@ -306,7 +279,7 @@ const Map: Component = () => {
|
||||||
]),
|
]),
|
||||||
});
|
});
|
||||||
olMap.on(['moveend'], changeListener);
|
olMap.on(['moveend'], changeListener);
|
||||||
olMap.on(['dblclick'], clickHandler);
|
olMap.on(['singleclick'], clickHandler);
|
||||||
|
|
||||||
setMap(olMap);
|
setMap(olMap);
|
||||||
});
|
});
|
||||||
|
@ -314,28 +287,17 @@ const Map: Component = () => {
|
||||||
return (
|
return (
|
||||||
//<OsmFetch map={getMap} />
|
//<OsmFetch map={getMap} />
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
<div
|
<div class='ol-map' ref={target}>
|
||||||
class='ol-map'
|
|
||||||
ref={target}
|
|
||||||
ondrop={dropHandler}
|
|
||||||
ondragover={dragOverHandler}
|
|
||||||
ondragenter={dragEnterHandler}
|
|
||||||
>
|
|
||||||
<Updater />
|
|
||||||
<Invitation />
|
|
||||||
<Overlays map={getMap} />
|
<Overlays map={getMap} />
|
||||||
<Note />
|
|
||||||
<Finder />
|
<Finder />
|
||||||
<GetLocation />
|
<GetLocation />
|
||||||
<Show when={window.Capacitor.platform !== 'web'}>
|
<Forward />
|
||||||
<Forward />
|
<Back />
|
||||||
<Back />
|
<GpxRecord />
|
||||||
<GpxRecord />
|
|
||||||
</Show>
|
|
||||||
<GpxImport />
|
<GpxImport />
|
||||||
<MapTileProvider />
|
<MapTileProvider />
|
||||||
<GpxDialog />
|
<GpxDialog />
|
||||||
<SystemDrawer />
|
<Account />
|
||||||
<AllGpxes map={getMap} />
|
<AllGpxes map={getMap} />
|
||||||
<Infos />
|
<Infos />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
.control {
|
|
||||||
opacity: 1;
|
|
||||||
position: fixed !important;
|
|
||||||
top: 0px;
|
|
||||||
margin-left: calc(100% - 260px) !important;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.control_web {
|
|
||||||
opacity: 1;
|
|
||||||
position: fixed !important;
|
|
||||||
top: 0px;
|
|
||||||
margin-left: calc(100% - 220px) !important;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
|
@ -1,81 +0,0 @@
|
||||||
import { IconButton } from '@suid/material';
|
|
||||||
import { Component, createSignal, Show } from 'solid-js';
|
|
||||||
import { Geolocation } from '@awesome-cordova-plugins/geolocation';
|
|
||||||
|
|
||||||
import NoteIcon from '@suid/icons-material/Note';
|
|
||||||
|
|
||||||
import style from './Note.module.css';
|
|
||||||
import WptEditDialog, { Category } from '../wpt/WptEditDialog';
|
|
||||||
import { Coordinate } from 'ol/coordinate';
|
|
||||||
|
|
||||||
interface Props {}
|
|
||||||
|
|
||||||
const Note: Component<Props> = (props) => {
|
|
||||||
const [open, setOpen] = createSignal<boolean>(false);
|
|
||||||
const [coordinate, setCoordinate] = createSignal<Coordinate>();
|
|
||||||
|
|
||||||
const openWptEditDialogWithCurrentLocation = async () => {
|
|
||||||
const position = await Geolocation.getCurrentPosition();
|
|
||||||
setCoordinate([position.coords.longitude, position.coords.latitude]);
|
|
||||||
setOpen(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
const initialWpt = () => {
|
|
||||||
const time = new Date().toISOString();
|
|
||||||
return {
|
|
||||||
$: { lat: 0, lon: 0 },
|
|
||||||
ele: undefined,
|
|
||||||
time: undefined,
|
|
||||||
magvar: undefined,
|
|
||||||
geoidheight: undefined,
|
|
||||||
name: undefined,
|
|
||||||
cmt: undefined,
|
|
||||||
desc: undefined,
|
|
||||||
src: undefined,
|
|
||||||
link: undefined,
|
|
||||||
sym: undefined,
|
|
||||||
type: undefined,
|
|
||||||
fix: undefined,
|
|
||||||
sat: undefined,
|
|
||||||
hdop: undefined,
|
|
||||||
vdop: undefined,
|
|
||||||
pdop: undefined,
|
|
||||||
ageofdgpsdata: undefined,
|
|
||||||
dgpsid: undefined,
|
|
||||||
extensions: {
|
|
||||||
address: undefined,
|
|
||||||
startTime: time,
|
|
||||||
endTime: time,
|
|
||||||
category: Category.NOTE,
|
|
||||||
subCategory: undefined,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div
|
|
||||||
class={
|
|
||||||
window.Capacitor.platform === 'web'
|
|
||||||
? style.control_web
|
|
||||||
: style.control
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{' '}
|
|
||||||
<IconButton onClick={openWptEditDialogWithCurrentLocation}>
|
|
||||||
<NoteIcon />
|
|
||||||
</IconButton>
|
|
||||||
</div>
|
|
||||||
<Show when={open()}>
|
|
||||||
<WptEditDialog
|
|
||||||
open={open}
|
|
||||||
closeHandler={() => setOpen(false)}
|
|
||||||
coordinate={coordinate}
|
|
||||||
initialWpt={initialWpt}
|
|
||||||
/>
|
|
||||||
</Show>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Note;
|
|
|
@ -1 +0,0 @@
|
||||||
export { default } from './Note';
|
|
|
@ -3,20 +3,25 @@ import OlMap from 'ol/Map';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
currentOverlayDefinition,
|
currentOverlayDefinition,
|
||||||
isHighlightedTagType,
|
currentOverlayHighlightedDefinition,
|
||||||
|
isHighlighted,
|
||||||
} from '../map-tile-provider';
|
} from '../map-tile-provider';
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
|
import MVT from 'ol/format/MVT';
|
||||||
import { Point } from 'ol/geom';
|
import { Point } from 'ol/geom';
|
||||||
import VectorLayer from 'ol/layer/Vector';
|
import VectorLayer from 'ol/layer/Vector';
|
||||||
import VectorTileLayer from 'ol/layer/VectorTile';
|
import VectorTileLayer from 'ol/layer/VectorTile';
|
||||||
import VectorTileSource from 'ol/source/VectorTile.js';
|
import VectorTileSource from 'ol/source/VectorTile.js';
|
||||||
|
import WMTSTileGrid from 'ol/tilegrid/WMTS.js';
|
||||||
import Cluster from 'ol/source/Cluster';
|
import Cluster from 'ol/source/Cluster';
|
||||||
import { style } from '../gpx/styles';
|
import { style } from '../gpx/styles';
|
||||||
import ClusterableVectorTileSourceProxy from '../../lib/ClusterableVectorTileSourceProxy';
|
import ClusterableVectorTileSourceProxy from '../../lib/ClusterableVectorTileSourceProxy';
|
||||||
import { getMap, getZoomInteger } from '../map/Map';
|
import { getMap, getZoomInteger } from '../map/Map';
|
||||||
import { getCenter } from 'ol/extent';
|
import { getCenter } from 'ol/extent';
|
||||||
import { getTagType, getVectorTileFeatureType } from './overlay-definitions';
|
import { Projection } from 'ol/proj';
|
||||||
|
import { getVectorTileFeatureType } from './overlay-definitions';
|
||||||
import GeoJSON from 'ol/format/GeoJSON.js';
|
import GeoJSON from 'ol/format/GeoJSON.js';
|
||||||
|
import TopoJSON from 'ol/format/TopoJSON.js';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
map: () => OlMap | null;
|
map: () => OlMap | null;
|
||||||
|
@ -139,7 +144,7 @@ export const Overlays: Component<Props> = ({ map }) => {
|
||||||
if (
|
if (
|
||||||
getZoomInteger() < 16 &&
|
getZoomInteger() < 16 &&
|
||||||
getVectorTileFeatureType(feature) === 'poi' &&
|
getVectorTileFeatureType(feature) === 'poi' &&
|
||||||
isHighlightedTagType(getTagType(feature))
|
isHighlighted(feature)
|
||||||
) {
|
) {
|
||||||
return new Point(getCenter(feature.getGeometry().getExtent()));
|
return new Point(getCenter(feature.getGeometry().getExtent()));
|
||||||
}
|
}
|
||||||
|
@ -169,6 +174,7 @@ export const Overlays: Component<Props> = ({ map }) => {
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
const overlayDefinition = currentOverlayDefinition();
|
const overlayDefinition = currentOverlayDefinition();
|
||||||
|
const overlayHighlightedDefinition = currentOverlayHighlightedDefinition();
|
||||||
const olMap = getMap();
|
const olMap = getMap();
|
||||||
if (olMap) {
|
if (olMap) {
|
||||||
olMap.removeLayer(clusterLayer);
|
olMap.removeLayer(clusterLayer);
|
||||||
|
|
|
@ -1,6 +1 @@
|
||||||
import {
|
import { overlayDefinitions, overlayCategories } from './overlay-definitions';
|
||||||
overlayDefinitions,
|
|
||||||
OsmTag,
|
|
||||||
osmTags,
|
|
||||||
getTagType,
|
|
||||||
} from './overlay-definitions';
|
|
||||||
|
|
|
@ -1,284 +1,104 @@
|
||||||
|
import { indexOf } from 'lodash';
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
|
|
||||||
export interface OsmTag {
|
|
||||||
name: string;
|
|
||||||
value: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const osmTags = {
|
|
||||||
bar: { name: 'amenity', value: 'bar' },
|
|
||||||
fast_food: { name: 'amenity', value: 'fast_food' },
|
|
||||||
food_court: { name: 'amenity', value: 'food_court' },
|
|
||||||
pub: { name: 'amenity', value: 'pub' },
|
|
||||||
restaurant: { name: 'amenity', value: 'restaurant' },
|
|
||||||
cafe: { name: 'amenity', value: 'cafe' },
|
|
||||||
atm: { name: 'amenity', value: 'atm' },
|
|
||||||
bank: { name: 'amenity', value: 'bank' },
|
|
||||||
doctors: { name: 'amenity', value: 'doctors' },
|
|
||||||
hospital: { name: 'amenity', value: 'hospital' },
|
|
||||||
pharmacy: { name: 'amenity', value: 'pharmacy' },
|
|
||||||
police: { name: 'amenity', value: 'police' },
|
|
||||||
fire_station: { name: 'amenity', value: 'fire_station' },
|
|
||||||
drinking_water: { name: 'amenity', value: 'drinking_water' },
|
|
||||||
water_point: { name: 'amenity', value: 'water_point' },
|
|
||||||
waste_basket: { name: 'amenity', value: 'waste_basket' },
|
|
||||||
waste_disposal: { name: 'amenity', value: 'waste_disposal' },
|
|
||||||
vending_machine: { name: 'amenity', value: 'vending_machine' },
|
|
||||||
bicycle_parking: { name: 'amenity', value: 'bicycle_parking' },
|
|
||||||
parking: { name: 'amenity', value: 'parking' },
|
|
||||||
bakery: { name: 'shop', value: 'bakery' },
|
|
||||||
butcher: { name: 'shop', value: 'butcher' },
|
|
||||||
cheese: { name: 'shop', value: 'cheese' },
|
|
||||||
chocolate: { name: 'shop', value: 'chocolate' },
|
|
||||||
convenience: { name: 'shop', value: 'convenience' },
|
|
||||||
dairy: { name: 'shop', value: 'dairy' },
|
|
||||||
farm: { name: 'shop', value: 'farm' },
|
|
||||||
greengrocer: { name: 'shop', value: 'greengrocer' },
|
|
||||||
health_food: { name: 'shop', value: 'health_food' },
|
|
||||||
pasta: { name: 'shop', value: 'pasta' },
|
|
||||||
pastry: { name: 'shop', value: 'pastry' },
|
|
||||||
seafood: { name: 'shop', value: 'seafood' },
|
|
||||||
water: { name: 'shop', value: 'water' },
|
|
||||||
department_store: { name: 'shop', value: 'department_store' },
|
|
||||||
general: { name: 'shop', value: 'general' },
|
|
||||||
mall: { name: 'shop', value: 'mall' },
|
|
||||||
supermarket: { name: 'shop', value: 'supermarket' },
|
|
||||||
wholesale: { name: 'shop', value: 'wholesale' },
|
|
||||||
outdoor: { name: 'shop', value: 'outdoor' },
|
|
||||||
laundry: { name: 'shop', value: 'laundry' },
|
|
||||||
hotel: { name: 'tourism', value: 'hotel' },
|
|
||||||
alpine_hut: { name: 'tourism', value: 'alpine_hut' },
|
|
||||||
apartment: { name: 'tourism', value: 'apartment' },
|
|
||||||
camp_site: { name: 'tourism', value: 'camp_site' },
|
|
||||||
chalet: { name: 'tourism', value: 'chalet' },
|
|
||||||
guest_house: { name: 'tourism', value: 'guest_house' },
|
|
||||||
hostel: { name: 'tourism', value: 'hostel' },
|
|
||||||
motel: { name: 'tourism', value: 'motel' },
|
|
||||||
wilderness_hut: { name: 'tourism', value: 'wilderness_hut' },
|
|
||||||
viewpoint: { name: 'tourism', value: 'viewpoint' },
|
|
||||||
waterfall: { name: 'waterway', value: 'waterfall' },
|
|
||||||
peak: { name: 'natural', value: 'peak' },
|
|
||||||
cave_entrance: { name: 'natural', value: 'cave_entrance' },
|
|
||||||
volcano: { name: 'natural', value: 'volcano' },
|
|
||||||
arch: { name: 'natural', value: 'arch' },
|
|
||||||
arete: { name: 'natural', value: 'arete' },
|
|
||||||
fumarole: { name: 'natural', value: 'fumarole' },
|
|
||||||
rock: { name: 'natural', value: 'rock' },
|
|
||||||
saddle: { name: 'natural', value: 'saddle' },
|
|
||||||
sinkhole: { name: 'natural', value: 'sinkhole' },
|
|
||||||
stone: { name: 'natural', value: 'stone' },
|
|
||||||
glacier: { name: 'natural', value: 'glacier' },
|
|
||||||
spring: { name: 'natural', value: 'spring' },
|
|
||||||
hot_spring: { name: 'natural', value: 'hot_spring' },
|
|
||||||
geyser: { name: 'natural', value: 'geyser' },
|
|
||||||
};
|
|
||||||
|
|
||||||
export const overlayDefinitions = {
|
export const overlayDefinitions = {
|
||||||
hiking: {
|
amenity: {
|
||||||
drinking: ['bar', 'pub', 'cafe', 'drinking_water', 'water_point', 'water'],
|
bar: { hiking: { drinking: true } },
|
||||||
eating: [
|
fast_food: { hiking: { eating: true } },
|
||||||
'fast_food',
|
food_court: { hiking: { eating: true } },
|
||||||
'food_court',
|
pub: { hiking: { eating: true } },
|
||||||
'pub',
|
restaurant: { hiking: { eating: true } },
|
||||||
'restaurant',
|
cafe: { hiking: { drinking: true } },
|
||||||
'bakery',
|
atm: { hiking: { money: true, dayToDay: true } },
|
||||||
'butcher',
|
bank: { hiking: { money: true, dayToDay: true } },
|
||||||
'cheese',
|
doctors: { hiking: { health: true } },
|
||||||
'chocolate',
|
hospital: { hiking: { health: true } },
|
||||||
'convenience',
|
pharmacy: { hiking: { health: true } },
|
||||||
'dairy',
|
police: { hiking: { security: true } },
|
||||||
'farm',
|
fire_station: { hiking: { security: true } },
|
||||||
'greengrocer',
|
drinking_water: { hiking: { drinking: true } },
|
||||||
'health_food',
|
water_point: { hiking: { drinking: true } },
|
||||||
'pasta',
|
waste_basket: { hiking: { dayToDay: true } },
|
||||||
'pastry',
|
waste_disposal: { hiking: { dayToDay: true } },
|
||||||
'seafood',
|
vending_machine: { hiking: { dayToDay: true } },
|
||||||
'supermarket',
|
|
||||||
'wholesale',
|
|
||||||
'outdoor',
|
|
||||||
],
|
|
||||||
money: ['atm', 'bank'],
|
|
||||||
dayToDay: [
|
|
||||||
'atm',
|
|
||||||
'bank',
|
|
||||||
'waste_basket',
|
|
||||||
'waste_disposal',
|
|
||||||
'vending_machine',
|
|
||||||
'department_store',
|
|
||||||
'general',
|
|
||||||
'mall',
|
|
||||||
'laundry',
|
|
||||||
],
|
|
||||||
health: ['doctors', 'hospital', 'pharmacy'],
|
|
||||||
security: ['police', 'fire_station'],
|
|
||||||
sleeping: [
|
|
||||||
'hotel',
|
|
||||||
'alpine_hut',
|
|
||||||
'apartment',
|
|
||||||
'camp_site',
|
|
||||||
'chalet',
|
|
||||||
'guest_house',
|
|
||||||
'hostel',
|
|
||||||
'motel',
|
|
||||||
'wilderness_hut',
|
|
||||||
],
|
|
||||||
naturalSites: [
|
|
||||||
'viewpoint',
|
|
||||||
'waterfall',
|
|
||||||
'peak',
|
|
||||||
'cave_entrance',
|
|
||||||
'volcano',
|
|
||||||
'arch',
|
|
||||||
'arete',
|
|
||||||
'fumarole',
|
|
||||||
'rock',
|
|
||||||
'saddle',
|
|
||||||
'sinkhole',
|
|
||||||
'stone',
|
|
||||||
'glacier',
|
|
||||||
'spring',
|
|
||||||
'hot_spring',
|
|
||||||
'geyser',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
cycling: {
|
shop: {
|
||||||
drinking: ['bar', 'pub', 'cafe', 'drinking_water', 'water_point', 'water'],
|
bakery: { hiking: { eating: true } },
|
||||||
eating: [
|
butcher: { hiking: { eating: true } },
|
||||||
'fast_food',
|
cheese: { hiking: { eating: true } },
|
||||||
'food_court',
|
chocolate: { hiking: { eating: true } },
|
||||||
'pub',
|
convenience: { hiking: { eating: true } },
|
||||||
'restaurant',
|
dairy: { hiking: { eating: true } },
|
||||||
'bakery',
|
farm: { hiking: { eating: true } },
|
||||||
'butcher',
|
greengrocer: { hiking: { eating: true } },
|
||||||
'cheese',
|
health_food: { hiking: { eating: true } },
|
||||||
'chocolate',
|
pasta: { hiking: { eating: true } },
|
||||||
'convenience',
|
pastry: { hiking: { eating: true } },
|
||||||
'dairy',
|
seafood: { hiking: { eating: true } },
|
||||||
'farm',
|
water: { hiking: { drinking: true } },
|
||||||
'greengrocer',
|
department_store: { hiking: { dayToDay: true } },
|
||||||
'health_food',
|
general: { hiking: { dayToDay: true } },
|
||||||
'pasta',
|
mall: { hiking: { dayToDay: true } },
|
||||||
'pastry',
|
supermarket: { hiking: { eating: true } },
|
||||||
'seafood',
|
wholesale: { hiking: { eating: true } },
|
||||||
'supermarket',
|
outdoor: { hiking: { material: true } },
|
||||||
'wholesale',
|
laundry: { hiking: { dayToDay: true } },
|
||||||
'outdoor',
|
|
||||||
],
|
|
||||||
money: ['atm', 'bank'],
|
|
||||||
dayToDay: [
|
|
||||||
'atm',
|
|
||||||
'bank',
|
|
||||||
'waste_basket',
|
|
||||||
'waste_disposal',
|
|
||||||
'vending_machine',
|
|
||||||
'department_store',
|
|
||||||
'general',
|
|
||||||
'mall',
|
|
||||||
'laundry',
|
|
||||||
],
|
|
||||||
health: ['doctors', 'hospital', 'pharmacy'],
|
|
||||||
security: ['police', 'fire_station'],
|
|
||||||
parking: ['bicycle_parking'],
|
|
||||||
sleeping: [
|
|
||||||
'hotel',
|
|
||||||
'alpine_hut',
|
|
||||||
'apartment',
|
|
||||||
'camp_site',
|
|
||||||
'chalet',
|
|
||||||
'guest_house',
|
|
||||||
'hostel',
|
|
||||||
'motel',
|
|
||||||
'wilderness_hut',
|
|
||||||
],
|
|
||||||
naturalSites: [
|
|
||||||
'viewpoint',
|
|
||||||
'waterfall',
|
|
||||||
'peak',
|
|
||||||
'cave_entrance',
|
|
||||||
'volcano',
|
|
||||||
'arch',
|
|
||||||
'arete',
|
|
||||||
'fumarole',
|
|
||||||
'rock',
|
|
||||||
'saddle',
|
|
||||||
'sinkhole',
|
|
||||||
'stone',
|
|
||||||
'glacier',
|
|
||||||
'spring',
|
|
||||||
'hot_spring',
|
|
||||||
'geyser',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
vanlife: {
|
tourism: {
|
||||||
drinking: ['bar', 'pub', 'cafe', 'drinking_water', 'water_point', 'water'],
|
hotel: { hiking: { sleeping: true } },
|
||||||
eating: [
|
alpine_hut: { hiking: { sleeping: true } },
|
||||||
'fast_food',
|
apartment: { hiking: { sleeping: true } },
|
||||||
'food_court',
|
camp_site: { hiking: { sleeping: true } },
|
||||||
'pub',
|
chalet: { hiking: { sleeping: true } },
|
||||||
'restaurant',
|
guest_house: { hiking: { sleeping: true } },
|
||||||
'bakery',
|
hostel: { hiking: { sleeping: true } },
|
||||||
'butcher',
|
motel: { hiking: { sleeping: true } },
|
||||||
'cheese',
|
wilderness_hut: { hiking: { sleeping: true } },
|
||||||
'chocolate',
|
viewpoint: { hiking: { naturalSites: true } },
|
||||||
'convenience',
|
},
|
||||||
'dairy',
|
waterway: { waterfall: { hiking: { naturalSites: true } } },
|
||||||
'farm',
|
natural: {
|
||||||
'greengrocer',
|
peak: { hiking: { naturalSites: true } },
|
||||||
'health_food',
|
cave_entrance: { hiking: { naturalSites: true } },
|
||||||
'pasta',
|
volcano: { hiking: { naturalSites: true } },
|
||||||
'pastry',
|
arch: { hiking: { naturalSites: true } },
|
||||||
'seafood',
|
arete: { hiking: { naturalSites: true } },
|
||||||
'supermarket',
|
fumarole: { hiking: { naturalSites: true } },
|
||||||
'wholesale',
|
rock: { hiking: { naturalSites: true } },
|
||||||
'outdoor',
|
saddle: { hiking: { naturalSites: true } },
|
||||||
],
|
sinkhole: { hiking: { naturalSites: true } },
|
||||||
money: ['atm', 'bank'],
|
stone: { hiking: { naturalSites: true } },
|
||||||
dayToDay: [
|
glacier: { hiking: { naturalSites: true } },
|
||||||
'atm',
|
spring: { hiking: { naturalSites: true } },
|
||||||
'bank',
|
hot_spring: { hiking: { naturalSites: true } },
|
||||||
'waste_basket',
|
geyser: { hiking: { naturalSites: true } },
|
||||||
'waste_disposal',
|
|
||||||
'vending_machine',
|
|
||||||
'department_store',
|
|
||||||
'general',
|
|
||||||
'mall',
|
|
||||||
'laundry',
|
|
||||||
],
|
|
||||||
health: ['doctors', 'hospital', 'pharmacy'],
|
|
||||||
security: ['police', 'fire_station'],
|
|
||||||
parking: ['parking'],
|
|
||||||
sleeping: ['parking', 'camp_site'],
|
|
||||||
naturalSites: [
|
|
||||||
'viewpoint',
|
|
||||||
'waterfall',
|
|
||||||
'peak',
|
|
||||||
'cave_entrance',
|
|
||||||
'volcano',
|
|
||||||
'arch',
|
|
||||||
'arete',
|
|
||||||
'fumarole',
|
|
||||||
'rock',
|
|
||||||
'saddle',
|
|
||||||
'sinkhole',
|
|
||||||
'stone',
|
|
||||||
'glacier',
|
|
||||||
'spring',
|
|
||||||
'hot_spring',
|
|
||||||
'geyser',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getTagType = (feature: Feature) => {
|
let _flat: any = [];
|
||||||
for (const tagType of Object.keys(osmTags)) {
|
Object.values(overlayDefinitions).forEach((category) => {
|
||||||
const tag: OsmTag = osmTags[tagType];
|
Object.values(category).forEach((subCategory) => {
|
||||||
const tagValue = feature.get(tag.name);
|
_flat = [..._flat, subCategory];
|
||||||
if (tagValue === tag.value) {
|
});
|
||||||
return tagType;
|
});
|
||||||
}
|
|
||||||
}
|
type Categories = { string: Set<string> };
|
||||||
return false;
|
|
||||||
};
|
export let overlayCategories: Categories = {};
|
||||||
|
|
||||||
|
_flat.forEach((obj: any) => {
|
||||||
|
Object.keys(obj).forEach((catName: string) => {
|
||||||
|
const catValue = obj[catName];
|
||||||
|
const previous =
|
||||||
|
overlayCategories[catName] === undefined
|
||||||
|
? []
|
||||||
|
: overlayCategories[catName];
|
||||||
|
overlayCategories[catName] = new Set([
|
||||||
|
...previous,
|
||||||
|
...Object.keys(catValue),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
export const getVectorTileFeatureType = (feature: Feature) => {
|
export const getVectorTileFeatureType = (feature: Feature) => {
|
||||||
if (
|
if (
|
||||||
|
@ -287,7 +107,12 @@ export const getVectorTileFeatureType = (feature: Feature) => {
|
||||||
) {
|
) {
|
||||||
return 'way';
|
return 'way';
|
||||||
}
|
}
|
||||||
if (getTagType(feature)) {
|
if (
|
||||||
|
Object.keys(overlayDefinitions).some((tagName) => {
|
||||||
|
const tagValue = feature.get(tagName);
|
||||||
|
return Object.keys(overlayDefinitions[tagName]).includes(tagValue);
|
||||||
|
})
|
||||||
|
) {
|
||||||
return 'poi';
|
return 'poi';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -295,4 +120,6 @@ export const getVectorTileFeatureType = (feature: Feature) => {
|
||||||
console.log({
|
console.log({
|
||||||
caller: 'overlay-definitions',
|
caller: 'overlay-definitions',
|
||||||
overlayDefinitions,
|
overlayDefinitions,
|
||||||
|
_flat,
|
||||||
|
overlayCategories,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Component, createEffect, createSignal, onCleanup } from 'solid-js';
|
import { Component, createEffect, createSignal, onCleanup } from 'solid-js';
|
||||||
|
|
||||||
|
import dispatch, { cancelDispatch } from '../../workers/dispatcher-main';
|
||||||
import VectorSource from 'ol/source/Vector';
|
import VectorSource from 'ol/source/Vector';
|
||||||
import GeoJSON from 'ol/format/GeoJSON';
|
import GeoJSON from 'ol/format/GeoJSON';
|
||||||
import {
|
import {
|
||||||
|
@ -10,11 +11,11 @@ import { fromLonLat } from 'ol/proj';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
rteId: string;
|
rteId: string;
|
||||||
vectorSources: VectorSource[];
|
vectorSource: VectorSource;
|
||||||
context: any;
|
context: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Rte: Component<Props> = ({ vectorSources, rteId, context }) => {
|
export const Rte: Component<Props> = ({ vectorSource, rteId, context }) => {
|
||||||
const params = {
|
const params = {
|
||||||
id: rteId,
|
id: rteId,
|
||||||
method: 'getRte',
|
method: 'getRte',
|
||||||
|
@ -33,9 +34,9 @@ export const Rte: Component<Props> = ({ vectorSources, rteId, context }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
console.log({ caller: 'Rte', vectorSources, rteId, rte: rte() });
|
console.log({ caller: 'Rte', vectorSource, rteId, rte: rte() });
|
||||||
|
|
||||||
if (rte() && rte().rtept && rte().rtept.length > 0) {
|
if (rte()) {
|
||||||
let geo: any = {
|
let geo: any = {
|
||||||
type: 'FeatureCollection',
|
type: 'FeatureCollection',
|
||||||
features: [
|
features: [
|
||||||
|
@ -92,12 +93,12 @@ export const Rte: Component<Props> = ({ vectorSources, rteId, context }) => {
|
||||||
const features = new GeoJSON().readFeatures(geo);
|
const features = new GeoJSON().readFeatures(geo);
|
||||||
console.log({ caller: 'Rte', features });
|
console.log({ caller: 'Rte', features });
|
||||||
[`${rteId}/start`, rteId, `${rteId}/end`].forEach((id) => {
|
[`${rteId}/start`, rteId, `${rteId}/end`].forEach((id) => {
|
||||||
const feature = vectorSources[0].getFeatureById(id);
|
const feature = vectorSource.getFeatureById(id);
|
||||||
if (feature) {
|
if (feature) {
|
||||||
vectorSources[0].removeFeature(feature);
|
vectorSource.removeFeature(feature);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
vectorSources[0].addFeatures(features);
|
vectorSource.addFeatures(features);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import DeleteIcon from '@suid/icons-material/Delete';
|
||||||
import QuestionMarkIcon from '@suid/icons-material/QuestionMark';
|
import QuestionMarkIcon from '@suid/icons-material/QuestionMark';
|
||||||
import Tree from '../tree';
|
import Tree from '../tree';
|
||||||
import { LineString } from 'ol/geom';
|
import { LineString } from 'ol/geom';
|
||||||
import { DisplayOrGetStartEndAddresses } from '../display-or-get-address';
|
import DisplayOrGetAddress from '../display-or-get-address';
|
||||||
import { getFormattedLength } from '../../lib/ol';
|
import { getFormatedLength } from '../../lib/ol';
|
||||||
import Alert from '../alert';
|
import Alert from '../alert';
|
||||||
import dispatch from '../../workers/dispatcher-main';
|
import dispatch from '../../workers/dispatcher-main';
|
||||||
|
|
||||||
|
@ -73,11 +73,17 @@ const RteViewer: Component<Props> = ({ rteId }) => {
|
||||||
content={
|
content={
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
{getFormattedLength(lineString)}
|
{getFormatedLength(lineString)} {t('from')}{' '}
|
||||||
<DisplayOrGetStartEndAddresses
|
<DisplayOrGetAddress
|
||||||
id={rteId}
|
target={() => rte().rtept.at(0)}
|
||||||
wpts={() => rte().rtept}
|
|
||||||
putAction='putRtept'
|
putAction='putRtept'
|
||||||
|
putParamName='rtept'
|
||||||
|
/>{' '}
|
||||||
|
{t('to')}{' '}
|
||||||
|
<DisplayOrGetAddress
|
||||||
|
target={() => rte().rtept.at(-1)}
|
||||||
|
putAction='putRtept'
|
||||||
|
putParamName='rtept'
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
import { Component, createSignal } from 'solid-js';
|
|
||||||
|
|
||||||
import SettingsIcon from '@suid/icons-material/Settings';
|
|
||||||
|
|
||||||
import style from './SystemDrawer.module.css';
|
|
||||||
import {
|
|
||||||
Box,
|
|
||||||
Drawer,
|
|
||||||
IconButton,
|
|
||||||
List,
|
|
||||||
ListItem,
|
|
||||||
ListItemButton,
|
|
||||||
} from '@suid/material';
|
|
||||||
import Account from '../account';
|
|
||||||
import SystemInfo from '../system-info/SystemInfo';
|
|
||||||
|
|
||||||
interface Props {}
|
|
||||||
|
|
||||||
const SystemDrawer: Component<Props> = (props) => {
|
|
||||||
const [open, setOpen] = createSignal(false);
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div class={style.control}>
|
|
||||||
<IconButton onClick={() => setOpen(true)}>
|
|
||||||
<SettingsIcon />
|
|
||||||
</IconButton>
|
|
||||||
<Drawer open={open()} onClose={() => setOpen(false)} anchor='right'>
|
|
||||||
<Box
|
|
||||||
sx={{ width: '100%', maxWidth: 200, bgcolor: 'background.paper' }}
|
|
||||||
>
|
|
||||||
<List>
|
|
||||||
<Account />
|
|
||||||
<SystemInfo />
|
|
||||||
</List>
|
|
||||||
</Box>
|
|
||||||
</Drawer>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default SystemDrawer;
|
|
|
@ -1 +0,0 @@
|
||||||
export { default } from './SystemDrawer';
|
|
|
@ -1,3 +0,0 @@
|
||||||
.clickPrompt {
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
|
@ -1,146 +0,0 @@
|
||||||
import {
|
|
||||||
ListItem,
|
|
||||||
ListItemButton,
|
|
||||||
ListItemIcon,
|
|
||||||
ListItemText,
|
|
||||||
} from '@suid/material';
|
|
||||||
import {
|
|
||||||
Component,
|
|
||||||
createEffect,
|
|
||||||
createSignal,
|
|
||||||
For,
|
|
||||||
onMount,
|
|
||||||
Show,
|
|
||||||
} from 'solid-js';
|
|
||||||
import SystemSecurityUpdateWarningIcon from '@suid/icons-material/SystemSecurityUpdateWarning';
|
|
||||||
import Dialog from '../dialog';
|
|
||||||
import dispatch from '../../workers/dispatcher-main';
|
|
||||||
import { sleep } from '../../lib/async-wait';
|
|
||||||
import style from './SystemInfo.module.css';
|
|
||||||
|
|
||||||
const [error, setError] = createSignal<any[]>([]);
|
|
||||||
|
|
||||||
export const reportError = (err: any) => {
|
|
||||||
setError([...error(), err]);
|
|
||||||
};
|
|
||||||
|
|
||||||
interface Props {}
|
|
||||||
|
|
||||||
const SystemInfo: Component<Props> = (props) => {
|
|
||||||
const [open, setOpen] = createSignal(false);
|
|
||||||
const [settings, setSettings] = createSignal<any>();
|
|
||||||
const [account, setAccount] = createSignal<any>();
|
|
||||||
|
|
||||||
createEffect(() => {
|
|
||||||
if (error().length > 0 && !open()) {
|
|
||||||
openDialog();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const selfTest = async () => {
|
|
||||||
try {
|
|
||||||
const pong = await dispatch({
|
|
||||||
action: 'ping',
|
|
||||||
params: { what: 'ping' },
|
|
||||||
});
|
|
||||||
if (pong !== 'ping pong') {
|
|
||||||
throw new Error(
|
|
||||||
`web worker test error, received "${pong}" instead of expected "ping pong"`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
reportError(err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
selfTest();
|
|
||||||
|
|
||||||
const openDialog = async () => {
|
|
||||||
setOpen(true);
|
|
||||||
try {
|
|
||||||
const sets: any = await dispatch({
|
|
||||||
action: 'getSettings',
|
|
||||||
});
|
|
||||||
setSettings(sets);
|
|
||||||
const acc: any = await dispatch({
|
|
||||||
action: 'getAccount',
|
|
||||||
params: { id: settings().currentAccountId },
|
|
||||||
});
|
|
||||||
setAccount(acc);
|
|
||||||
} catch (err) {
|
|
||||||
reportError(err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let content: any;
|
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
if (!!content) {
|
|
||||||
content.onclick = function () {
|
|
||||||
document.execCommand('copy');
|
|
||||||
};
|
|
||||||
|
|
||||||
content.addEventListener('copy', function (event: any) {
|
|
||||||
event.preventDefault();
|
|
||||||
if (event.clipboardData) {
|
|
||||||
event.clipboardData.setData('text/plain', content.textContent);
|
|
||||||
console.log(event.clipboardData.getData('text'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const clickHandler = async (event: any) => {
|
|
||||||
const range = document.createRange();
|
|
||||||
range.selectNode(content);
|
|
||||||
window.getSelection()?.removeAllRanges();
|
|
||||||
window.getSelection()?.addRange(range);
|
|
||||||
document.execCommand('copy');
|
|
||||||
await sleep(300);
|
|
||||||
window.getSelection()?.removeAllRanges();
|
|
||||||
console.log({ caller: 'SystemInfo / clickHandler', event, range });
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<ListItem>
|
|
||||||
<ListItemButton onClick={openDialog}>
|
|
||||||
<ListItemIcon>
|
|
||||||
<SystemSecurityUpdateWarningIcon />
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText>System Info</ListItemText>
|
|
||||||
</ListItemButton>
|
|
||||||
</ListItem>
|
|
||||||
<Show when={open()}>
|
|
||||||
<Dialog
|
|
||||||
open={open()}
|
|
||||||
closeHandler={() => setOpen(false)}
|
|
||||||
title='System info'
|
|
||||||
>
|
|
||||||
<div onclick={clickHandler}>
|
|
||||||
<div class={style.clickPrompt}>Click to copy to clipboard</div>
|
|
||||||
<div ref={content}>
|
|
||||||
<p>Platform: {window.Capacitor.platform}</p>
|
|
||||||
<p>User agent: {navigator.userAgent}</p>
|
|
||||||
<p>App release: {import.meta.env.VITE_GIT_COMMIT_HASH}</p>
|
|
||||||
<p>Account id: {settings()?.currentAccountId}</p>
|
|
||||||
<p>Account name: {account()?.name}</p>
|
|
||||||
<p>Remote DB user: {account()?.remoteDbUser}</p>
|
|
||||||
<p>Remote DB server: {account()?.remoteDbServer}</p>
|
|
||||||
</div>
|
|
||||||
<Show when={error().length > 0}>
|
|
||||||
<div>
|
|
||||||
<p>Errors:</p>
|
|
||||||
<ul>
|
|
||||||
<For each={error()}>{(item) => <li>{item.message}</li>}</For>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
</div>
|
|
||||||
</Dialog>
|
|
||||||
</Show>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default SystemInfo;
|
|
|
@ -1 +0,0 @@
|
||||||
export { default, reportError } from './SystemInfo';
|
|
|
@ -1,4 +1,17 @@
|
||||||
import { Component, createEffect, For, onCleanup, Suspense } from 'solid-js';
|
import {
|
||||||
|
Component,
|
||||||
|
createEffect,
|
||||||
|
createResource,
|
||||||
|
createSignal,
|
||||||
|
For,
|
||||||
|
onCleanup,
|
||||||
|
Suspense,
|
||||||
|
} from 'solid-js';
|
||||||
|
|
||||||
|
import OlMap from 'ol/Map';
|
||||||
|
|
||||||
|
import dispatch, { cancelDispatch } from '../../workers/dispatcher-main';
|
||||||
|
import getUri from '../../lib/ids';
|
||||||
|
|
||||||
import Trkseg from '../trkseg';
|
import Trkseg from '../trkseg';
|
||||||
import VectorSource from 'ol/source/Vector';
|
import VectorSource from 'ol/source/Vector';
|
||||||
|
@ -9,16 +22,10 @@ import {
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
trkId: string;
|
trkId: string;
|
||||||
vectorSources: VectorSource[];
|
vectorSource: VectorSource;
|
||||||
context: any;
|
context: any;
|
||||||
tags: any;
|
|
||||||
}
|
}
|
||||||
export const Trk: Component<Props> = ({
|
export const Trk: Component<Props> = ({ vectorSource, trkId, context }) => {
|
||||||
vectorSources,
|
|
||||||
trkId,
|
|
||||||
context,
|
|
||||||
tags,
|
|
||||||
}) => {
|
|
||||||
const params = {
|
const params = {
|
||||||
id: trkId,
|
id: trkId,
|
||||||
method: 'getTrk',
|
method: 'getTrk',
|
||||||
|
@ -31,7 +38,7 @@ export const Trk: Component<Props> = ({
|
||||||
});
|
});
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
console.log({ caller: 'Trk', vectorSources, trkId, trk: trk() });
|
console.log({ caller: 'Trk', vectorSource, trkId, trk: trk() });
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -42,10 +49,9 @@ export const Trk: Component<Props> = ({
|
||||||
return (
|
return (
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<Trkseg
|
<Trkseg
|
||||||
vectorSources={vectorSources}
|
vectorSource={vectorSource}
|
||||||
trksegId={trksegId}
|
trksegId={trksegId}
|
||||||
context={{ ...context, trk, trkId }}
|
context={{ ...context, trk, trkId }}
|
||||||
tags={tags}
|
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
);
|
);
|
||||||
|
|
|
@ -11,16 +11,14 @@ import { fromLonLat } from 'ol/proj';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
trksegId: string;
|
trksegId: string;
|
||||||
vectorSources: VectorSource[];
|
vectorSource: VectorSource;
|
||||||
context: any;
|
context: any;
|
||||||
tags: any;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Trkseg: Component<Props> = ({
|
export const Trkseg: Component<Props> = ({
|
||||||
vectorSources,
|
vectorSource,
|
||||||
trksegId,
|
trksegId,
|
||||||
context,
|
context,
|
||||||
tags,
|
|
||||||
}) => {
|
}) => {
|
||||||
const params = {
|
const params = {
|
||||||
id: trksegId,
|
id: trksegId,
|
||||||
|
@ -30,61 +28,29 @@ export const Trkseg: Component<Props> = ({
|
||||||
|
|
||||||
const clearFeatures = () => {
|
const clearFeatures = () => {
|
||||||
[`${trksegId}/start`, trksegId, `${trksegId}/end`].forEach((id) => {
|
[`${trksegId}/start`, trksegId, `${trksegId}/end`].forEach((id) => {
|
||||||
vectorSources.forEach((vectorSource) => {
|
const feature = vectorSource.getFeatureById(id);
|
||||||
const feature = vectorSource.getFeatureById(id);
|
if (feature) {
|
||||||
if (feature) {
|
vectorSource.removeFeature(feature);
|
||||||
vectorSource.removeFeature(feature);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const positions = () => {
|
|
||||||
let result = new Set<string>();
|
|
||||||
if (context.trk && context.gpx) {
|
|
||||||
const trkId = context.trkId;
|
|
||||||
if (trkId === context.gpx().trk.at(0)) {
|
|
||||||
result.add('gpx-start');
|
|
||||||
}
|
|
||||||
if (trkId === context.gpx().trk.at(-1)) {
|
|
||||||
result.add('gpx-end');
|
|
||||||
}
|
|
||||||
if (trksegId === context.trk().trkseg.at(0)) {
|
|
||||||
result.add('trk-start');
|
|
||||||
}
|
|
||||||
if (trksegId === context.trk().trkseg.at(-1)) {
|
|
||||||
result.add('trk-end');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
console.log({
|
console.log({
|
||||||
caller: 'Trkseg / onCleanup',
|
caller: 'Trkseg / onCleanup',
|
||||||
trksegId,
|
trksegId,
|
||||||
trkseg: trkseg(),
|
trkseg: trkseg(),
|
||||||
params,
|
params,
|
||||||
context,
|
|
||||||
});
|
});
|
||||||
destroyCachedSignal(params);
|
destroyCachedSignal(params);
|
||||||
clearFeatures();
|
clearFeatures();
|
||||||
});
|
});
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
console.log({
|
console.log({ caller: 'Trkseg', vectorSource, trksegId, trkseg: trkseg() });
|
||||||
caller: 'Trkseg',
|
|
||||||
vectorSources,
|
|
||||||
trksegId,
|
|
||||||
trkseg: trkseg(),
|
|
||||||
context,
|
|
||||||
trk: context.trk(),
|
|
||||||
});
|
|
||||||
|
|
||||||
clearFeatures();
|
if (trkseg()) {
|
||||||
|
let geo: any = {
|
||||||
if (trkseg() && trkseg().trkpt && trkseg().trkpt.length > 0) {
|
|
||||||
let geoCluttered: any = {
|
|
||||||
type: 'FeatureCollection',
|
type: 'FeatureCollection',
|
||||||
features: [
|
features: [
|
||||||
{
|
{
|
||||||
|
@ -100,8 +66,6 @@ export const Trkseg: Component<Props> = ({
|
||||||
type: 'trkseg-start',
|
type: 'trkseg-start',
|
||||||
id: trksegId,
|
id: trksegId,
|
||||||
context: { ...context, trkseg, trksegId },
|
context: { ...context, trkseg, trksegId },
|
||||||
positions: positions(),
|
|
||||||
tags,
|
|
||||||
},
|
},
|
||||||
id: `${trksegId}/start`,
|
id: `${trksegId}/start`,
|
||||||
},
|
},
|
||||||
|
@ -117,17 +81,9 @@ export const Trkseg: Component<Props> = ({
|
||||||
type: 'trkseg',
|
type: 'trkseg',
|
||||||
id: trksegId,
|
id: trksegId,
|
||||||
context: { ...context, trkseg, trksegId },
|
context: { ...context, trkseg, trksegId },
|
||||||
positions: positions(),
|
|
||||||
tags,
|
|
||||||
},
|
},
|
||||||
id: trksegId,
|
id: trksegId,
|
||||||
},
|
},
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
let geoUnCluttered: any = {
|
|
||||||
type: 'FeatureCollection',
|
|
||||||
features: [
|
|
||||||
{
|
{
|
||||||
type: 'Feature',
|
type: 'Feature',
|
||||||
geometry: {
|
geometry: {
|
||||||
|
@ -141,16 +97,16 @@ export const Trkseg: Component<Props> = ({
|
||||||
type: 'trkseg-finish',
|
type: 'trkseg-finish',
|
||||||
id: trksegId,
|
id: trksegId,
|
||||||
context: { ...context, trkseg, trksegId },
|
context: { ...context, trkseg, trksegId },
|
||||||
positions: positions(),
|
|
||||||
tags,
|
|
||||||
},
|
},
|
||||||
id: `${trksegId}/end`,
|
id: `${trksegId}/end`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
vectorSources[0].addFeatures(new GeoJSON().readFeatures(geoCluttered));
|
const features = new GeoJSON().readFeatures(geo);
|
||||||
vectorSources[1].addFeatures(new GeoJSON().readFeatures(geoUnCluttered));
|
console.log({ caller: 'Trkseg', features });
|
||||||
|
clearFeatures();
|
||||||
|
vectorSource.addFeatures(features);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,9 @@ import { peekCachedSignal } from '../../workers/cached-signals';
|
||||||
import Tree from '../tree';
|
import Tree from '../tree';
|
||||||
import TrkIcon from '../../icons/human-footprints-svgrepo-com.svg?component-solid';
|
import TrkIcon from '../../icons/human-footprints-svgrepo-com.svg?component-solid';
|
||||||
import { useI18n } from '@solid-primitives/i18n';
|
import { useI18n } from '@solid-primitives/i18n';
|
||||||
import { getFormattedLength } from '../../lib/ol';
|
import { getFormatedLength } from '../../lib/ol';
|
||||||
import { DisplayOrGetStartEndAddresses } from '../display-or-get-address';
|
import DisplayOrGetAddress from '../display-or-get-address';
|
||||||
import { LineString } from 'ol/geom';
|
import { LineString } from 'ol/geom';
|
||||||
import { getFormattedHeightStats } from '../../lib/height';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
trksegId: string;
|
trksegId: string;
|
||||||
|
@ -41,13 +40,18 @@ const TrksegViewer: Component<Props> = ({ trksegId }) => {
|
||||||
content={
|
content={
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
{getFormattedLength(lineString)}{' '}
|
{getFormatedLength(lineString)} {t('from')}{' '}
|
||||||
<DisplayOrGetStartEndAddresses
|
<DisplayOrGetAddress
|
||||||
id={trksegId}
|
target={firstTrkpt}
|
||||||
wpts={() => trkseg().trkpt}
|
|
||||||
putAction='putTrkpt'
|
putAction='putTrkpt'
|
||||||
/>{', '}
|
putParamName='trkpt'
|
||||||
{getFormattedHeightStats(trkseg().trkpt)}
|
/>{' '}
|
||||||
|
{t('to')}{' '}
|
||||||
|
<DisplayOrGetAddress
|
||||||
|
target={lastTrkpt}
|
||||||
|
putAction='putTrkpt'
|
||||||
|
putParamName='trkpt'
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
.mobile {
|
|
||||||
position: fixed;
|
|
||||||
z-index: 1;
|
|
||||||
padding-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.web {
|
|
||||||
position: fixed;
|
|
||||||
z-index: 1;
|
|
||||||
left: 40px;
|
|
||||||
padding-top: 20px;
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
import { Alert, Button } from '@suid/material';
|
|
||||||
import { Component, createSignal, onCleanup, Show } from 'solid-js';
|
|
||||||
import { Browser } from '@capacitor/browser';
|
|
||||||
import style from './Updater.module.css';
|
|
||||||
|
|
||||||
interface Props {}
|
|
||||||
|
|
||||||
const Updater: Component<Props> = (props) => {
|
|
||||||
const [updateNeeded, setUpdateNeeded] = createSignal(false);
|
|
||||||
|
|
||||||
const checkUpdate = async () => {
|
|
||||||
const response = await fetch(
|
|
||||||
'https://dyomedea.app/assets/release/dyomedea.rel',
|
|
||||||
{
|
|
||||||
mode: 'cors', // no-cors, *cors, same-origin
|
|
||||||
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
|
|
||||||
credentials: 'same-origin',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const latestRelease = (await response.text()).replace('\n', '');
|
|
||||||
const currentRelease = import.meta.env.VITE_GIT_COMMIT_HASH;
|
|
||||||
console.log({ caller: 'checkUpdate', currentRelease, latestRelease });
|
|
||||||
setUpdateNeeded(latestRelease !== currentRelease);
|
|
||||||
};
|
|
||||||
|
|
||||||
const intervalId = setInterval(checkUpdate, 10 * 60 * 1000);
|
|
||||||
|
|
||||||
checkUpdate();
|
|
||||||
|
|
||||||
onCleanup(() => {
|
|
||||||
clearInterval(intervalId);
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Show when={updateNeeded()}>
|
|
||||||
<Show when={window.Capacitor.platform === 'android'}>
|
|
||||||
<div class={style.mobile}>
|
|
||||||
<Alert severity='warning'>
|
|
||||||
The app needs to be updated
|
|
||||||
<Button
|
|
||||||
variant='outlined'
|
|
||||||
onclick={() => {
|
|
||||||
Browser.open({
|
|
||||||
url: 'https://dyomedea.app/assets/release/dyomedea.apk',
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Update
|
|
||||||
</Button>
|
|
||||||
</Alert>
|
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
<Show when={window.Capacitor.platform === 'web'}>
|
|
||||||
<div class={style.web}>
|
|
||||||
<Alert severity='warning' class={style.mobile}>
|
|
||||||
Please reload this page to update the application.
|
|
||||||
</Alert>
|
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
</Show>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Updater;
|
|
|
@ -1 +0,0 @@
|
||||||
export { default } from './Updater';
|
|
|
@ -12,12 +12,12 @@ import { fromLonLat } from 'ol/proj';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
wptId: string;
|
wptId: string;
|
||||||
vectorSources: VectorSource[];
|
vectorSource: VectorSource;
|
||||||
context: any;
|
context: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Wpt: Component<Props> = ({
|
export const Wpt: Component<Props> = ({
|
||||||
vectorSources,
|
vectorSource,
|
||||||
wptId: wptId,
|
wptId: wptId,
|
||||||
context,
|
context,
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -48,12 +48,12 @@ export const Wpt: Component<Props> = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
console.log({ caller: 'Wpt', vectorSources, wptId, wpt: cloneDeep(wpt()) });
|
console.log({ caller: 'Wpt', vectorSource, wptId, wpt: cloneDeep(wpt()) });
|
||||||
|
|
||||||
if (wpt()) {
|
if (wpt()) {
|
||||||
const existingFeature = vectorSources[0].getFeatureById(wptId);
|
const existingFeature = vectorSource.getFeatureById(wptId);
|
||||||
if (existingFeature) {
|
if (existingFeature) {
|
||||||
vectorSources[0].removeFeature(existingFeature);
|
vectorSource.removeFeature(existingFeature);
|
||||||
}
|
}
|
||||||
let geo: any = {
|
let geo: any = {
|
||||||
type: 'FeatureCollection',
|
type: 'FeatureCollection',
|
||||||
|
@ -78,19 +78,11 @@ export const Wpt: Component<Props> = ({
|
||||||
|
|
||||||
const features = new GeoJSON().readFeatures(geo);
|
const features = new GeoJSON().readFeatures(geo);
|
||||||
console.log({ caller: 'Wpt', features });
|
console.log({ caller: 'Wpt', features });
|
||||||
const feature0 = vectorSources[0].getFeatureById(wptId);
|
const feature = vectorSource.getFeatureById(wptId);
|
||||||
if (feature0) {
|
if (feature) {
|
||||||
vectorSources[0].removeFeature(feature0);
|
vectorSource.removeFeature(feature);
|
||||||
}
|
|
||||||
const feature1 = vectorSources[1].getFeatureById(wptId);
|
|
||||||
if (feature1) {
|
|
||||||
vectorSources[1].removeFeature(feature1);
|
|
||||||
}
|
|
||||||
if (false && wpt()?.extensions?.category === 'note') {
|
|
||||||
vectorSources[1].addFeatures(features);
|
|
||||||
} else {
|
|
||||||
vectorSources[0].addFeatures(features);
|
|
||||||
}
|
}
|
||||||
|
vectorSource.addFeatures(features);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,4 @@
|
||||||
import {
|
import { Box, Button, Stack, TextField } from '@suid/material';
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
FormControl,
|
|
||||||
InputLabel,
|
|
||||||
NativeSelect,
|
|
||||||
Stack,
|
|
||||||
TextField,
|
|
||||||
} from '@suid/material';
|
|
||||||
import { Component, createEffect, createSignal, Show } from 'solid-js';
|
import { Component, createEffect, createSignal, Show } from 'solid-js';
|
||||||
import { useI18n } from '@solid-primitives/i18n';
|
import { useI18n } from '@solid-primitives/i18n';
|
||||||
|
|
||||||
|
@ -23,41 +15,20 @@ import { emptyGpx } from '../../db/gpx';
|
||||||
import getUri from '../../lib/ids';
|
import getUri from '../../lib/ids';
|
||||||
import { Coordinate } from 'ol/coordinate';
|
import { Coordinate } from 'ol/coordinate';
|
||||||
|
|
||||||
export enum Category {
|
|
||||||
NOTE = 'note',
|
|
||||||
POI = 'poi',
|
|
||||||
PICTURE = 'picture',
|
|
||||||
UNKNOWN = '',
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum SubCategory {
|
|
||||||
ACCOMMODATION = 'accommodation',
|
|
||||||
UNKNOWN = '',
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
wptId?: string;
|
wptId?: string;
|
||||||
coordinate?: () => Coordinate | undefined;
|
coordinate?: () => Coordinate | undefined;
|
||||||
open: () => boolean;
|
open: () => boolean;
|
||||||
closeHandler?: () => void;
|
closeHandler?: () => vpod;
|
||||||
initialWpt: () => Wpt;
|
|
||||||
imageUrl?: string | undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const WptEditDialog: Component<Props> = (props) => {
|
const WptEditDialog: Component<Props> = (props) => {
|
||||||
const {
|
const { wptId, closeHandler, open, coordinate } = props;
|
||||||
wptId,
|
|
||||||
closeHandler,
|
|
||||||
open,
|
|
||||||
coordinate,
|
|
||||||
initialWpt = () => emptyWpt,
|
|
||||||
imageUrl,
|
|
||||||
} = props;
|
|
||||||
const [t, { add, locale, dict }] = useI18n();
|
const [t, { add, locale, dict }] = useI18n();
|
||||||
|
|
||||||
const wpt = !!wptId
|
const wpt = !!wptId
|
||||||
? peekCachedSignal({ id: wptId, method: 'getWpt' })
|
? peekCachedSignal({ id: wptId, method: 'getWpt' })
|
||||||
: initialWpt;
|
: () => emptyWpt;
|
||||||
|
|
||||||
const [gpxId, setGpxId] = !wptId
|
const [gpxId, setGpxId] = !wptId
|
||||||
? createSignal<string>(currentGpxId())
|
? createSignal<string>(currentGpxId())
|
||||||
|
@ -136,7 +107,7 @@ const WptEditDialog: Component<Props> = (props) => {
|
||||||
action: 'putWpt',
|
action: 'putWpt',
|
||||||
params: { id: newWptId, wpt: editedWpt() },
|
params: { id: newWptId, wpt: editedWpt() },
|
||||||
});
|
});
|
||||||
setEditedWpt(undefined);
|
|
||||||
_closeHandler();
|
_closeHandler();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -147,25 +118,6 @@ const WptEditDialog: Component<Props> = (props) => {
|
||||||
return t('wpt');
|
return t('wpt');
|
||||||
};
|
};
|
||||||
|
|
||||||
// <TextField
|
|
||||||
// label={t('sym')}
|
|
||||||
// defaultValue={wpt()?.sym}
|
|
||||||
// onChange={(event: any, value: string) => {
|
|
||||||
// setEditedWpt({ ...editedWpt(), sym: value });
|
|
||||||
// }}
|
|
||||||
// />
|
|
||||||
// <TextField
|
|
||||||
// label={t('minZoom')}
|
|
||||||
// defaultValue={wpt()?.extensions?.['dyo:minZoom']?.toString()}
|
|
||||||
// onChange={(event: any, value: string) => {
|
|
||||||
// const extensions = {
|
|
||||||
// ...editedWpt()?.extensions,
|
|
||||||
// 'dyo:minZoom': parseFloat(value),
|
|
||||||
// };
|
|
||||||
// setEditedWpt({ ...editedWpt(), extensions });
|
|
||||||
// }}
|
|
||||||
// />
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
open={open() && !!wpt()}
|
open={open() && !!wpt()}
|
||||||
|
@ -195,50 +147,24 @@ const WptEditDialog: Component<Props> = (props) => {
|
||||||
setEditedWpt({ ...editedWpt(), name: value });
|
setEditedWpt({ ...editedWpt(), name: value });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<FormControl>
|
<TextField
|
||||||
<InputLabel variant='normal' htmlFor='category'>
|
label={t('sym')}
|
||||||
Type
|
defaultValue={wpt()?.sym}
|
||||||
</InputLabel>
|
onChange={(event: any, value: string) => {
|
||||||
<NativeSelect
|
setEditedWpt({ ...editedWpt(), sym: value });
|
||||||
inputProps={{
|
}}
|
||||||
name: 'category',
|
/>
|
||||||
id: 'category',
|
<TextField
|
||||||
}}
|
label={t('minZoom')}
|
||||||
onChange={(event: any, value: string) => {
|
defaultValue={wpt()?.extensions?.['dyo:minZoom']?.toString()}
|
||||||
setEditedWpt({
|
onChange={(event: any, value: string) => {
|
||||||
...editedWpt(),
|
const extensions = {
|
||||||
extensions: { ...editedWpt().extensions, category: value },
|
...editedWpt()?.extensions,
|
||||||
});
|
'dyo:minZoom': parseFloat(value),
|
||||||
}}
|
};
|
||||||
>
|
setEditedWpt({ ...editedWpt(), extensions });
|
||||||
<option
|
}}
|
||||||
value={Category.POI}
|
/>
|
||||||
selected={editedWpt()?.extensions?.category === Category.POI}
|
|
||||||
>
|
|
||||||
Point d'intérêt
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
value={Category.NOTE}
|
|
||||||
selected={editedWpt()?.extensions?.category === Category.NOTE}
|
|
||||||
>
|
|
||||||
Note
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
value={Category.PICTURE}
|
|
||||||
selected={
|
|
||||||
editedWpt()?.extensions?.category === Category.PICTURE
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Picture
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
value={undefined}
|
|
||||||
selected={!editedWpt()?.extensions?.category}
|
|
||||||
>
|
|
||||||
Autre
|
|
||||||
</option>
|
|
||||||
</NativeSelect>
|
|
||||||
</FormControl>
|
|
||||||
<TextField
|
<TextField
|
||||||
label={t('gpxDesc')}
|
label={t('gpxDesc')}
|
||||||
type='text'
|
type='text'
|
||||||
|
@ -250,34 +176,6 @@ const WptEditDialog: Component<Props> = (props) => {
|
||||||
}}
|
}}
|
||||||
InputProps={{ inputComponent: 'textarea' }}
|
InputProps={{ inputComponent: 'textarea' }}
|
||||||
/>
|
/>
|
||||||
<TextField
|
|
||||||
label='Début'
|
|
||||||
type='datetime-local'
|
|
||||||
value={(editedWpt()?.extensions?.startTime || '').replace('Z', '')}
|
|
||||||
onChange={(event: any) => {
|
|
||||||
setEditedWpt({
|
|
||||||
...editedWpt(),
|
|
||||||
extensions: {
|
|
||||||
...editedWpt().extensions,
|
|
||||||
startTime: new Date(event.target.value).toISOString(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<TextField
|
|
||||||
label='Fin'
|
|
||||||
type='datetime-local'
|
|
||||||
value={(editedWpt()?.extensions?.endTime || '').replace('Z', '')}
|
|
||||||
onChange={(event: any) => {
|
|
||||||
setEditedWpt({
|
|
||||||
...editedWpt(),
|
|
||||||
extensions: {
|
|
||||||
...editedWpt().extensions,
|
|
||||||
endTime: new Date(event.target.value).toISOString(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Stack spacing={2} direction='row' sx={{ marginTop: '20px' }}>
|
<Stack spacing={2} direction='row' sx={{ marginTop: '20px' }}>
|
||||||
<Button variant='outlined' color='secondary' onClick={closeHandler}>
|
<Button variant='outlined' color='secondary' onClick={closeHandler}>
|
||||||
{t('cancel')}
|
{t('cancel')}
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
.description {
|
|
||||||
white-space: pre-wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.date {
|
|
||||||
padding-top: 10px;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.thumbnail {
|
|
||||||
padding-top: 10px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
|
@ -1,121 +1,32 @@
|
||||||
import { Button, IconButton } from '@suid/material';
|
import { Component } from 'solid-js';
|
||||||
import { Component, createSignal, Show } from 'solid-js';
|
|
||||||
import WptIcon from '../../icons/location-pin-svgrepo-com.svg?component-solid';
|
import WptIcon from '../../icons/location-pin-svgrepo-com.svg?component-solid';
|
||||||
import { peekCachedSignal } from '../../workers/cached-signals';
|
import { peekCachedSignal } from '../../workers/cached-signals';
|
||||||
import dispatch from '../../workers/dispatcher-main';
|
|
||||||
import { useI18n } from '@solid-primitives/i18n';
|
|
||||||
import Tree from '../tree';
|
import Tree from '../tree';
|
||||||
import WptEditButtonAndDialog from './WptEditButtonAndDialog';
|
import WptEditButtonAndDialog from './WptEditButtonAndDialog';
|
||||||
import DeleteIcon from '@suid/icons-material/Delete';
|
|
||||||
import QuestionMarkIcon from '@suid/icons-material/QuestionMark';
|
|
||||||
import Alert from '../alert';
|
|
||||||
import style from './WptViewer.module.css';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
wptId: string;
|
wptId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const WptViewer: Component<Props> = ({ wptId }) => {
|
const WptViewer: Component<Props> = ({ wptId }) => {
|
||||||
const [t, { add, locale, dict }] = useI18n();
|
|
||||||
const wpt = peekCachedSignal({ id: wptId, method: 'getWpt' });
|
const wpt = peekCachedSignal({ id: wptId, method: 'getWpt' });
|
||||||
console.log({ caller: 'WptViewer', wptId, wpt: wpt() });
|
console.log({ caller: 'WptViewer', wptId, wpt: wpt() });
|
||||||
const title = () => {
|
const title = () => {
|
||||||
return wpt().name;
|
return wpt().name;
|
||||||
};
|
};
|
||||||
|
|
||||||
const [confirmDelete, setConfirmDelete] = createSignal(false);
|
|
||||||
|
|
||||||
const confirmDeleteHandler = () => {
|
|
||||||
console.log({
|
|
||||||
caller: 'WptViewer / confirmDeleteHandler',
|
|
||||||
wptId,
|
|
||||||
});
|
|
||||||
setConfirmDelete(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
const deleteHandler = () => {
|
|
||||||
console.log({
|
|
||||||
caller: 'WptViewer / deleteHandler',
|
|
||||||
wptId,
|
|
||||||
});
|
|
||||||
dispatch({ action: 'deleteWpt', params: { id: wptId } });
|
|
||||||
setConfirmDelete(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const cancelDeleteHandler = () => {
|
|
||||||
console.log({
|
|
||||||
caller: 'WptViewer / cancelDeleteHandler',
|
|
||||||
wptId,
|
|
||||||
});
|
|
||||||
setConfirmDelete(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Tree
|
||||||
<Tree
|
title={
|
||||||
title={
|
<>
|
||||||
<>
|
<WptIcon fill='black' width='24' height='24' viewBox='0 0 300 300' />
|
||||||
<WptIcon
|
{title()}
|
||||||
fill='black'
|
<WptEditButtonAndDialog wptId={wptId} />
|
||||||
width='24'
|
</>
|
||||||
height='24'
|
}
|
||||||
viewBox='0 0 300 300'
|
content={undefined}
|
||||||
/>
|
subTree={undefined}
|
||||||
{title()}
|
/>
|
||||||
<WptEditButtonAndDialog wptId={wptId} />
|
|
||||||
<div>
|
|
||||||
<IconButton onClick={confirmDeleteHandler}>
|
|
||||||
<DeleteIcon fill='white' />
|
|
||||||
</IconButton>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
content={
|
|
||||||
<div>
|
|
||||||
<div class={style.description}>{wpt().desc}</div>
|
|
||||||
<Show when={wpt().extensions?.thumbnailUrl}>
|
|
||||||
<div class={style.thumbnail}>
|
|
||||||
<img src={wpt().extensions?.thumbnailUrl}></img>
|
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
<Show when={wpt().extensions?.startTime}>
|
|
||||||
<div class={style.date}>
|
|
||||||
{new Date(wpt().extensions?.startTime).toLocaleDateString()}
|
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
subTree={undefined}
|
|
||||||
/>
|
|
||||||
<Alert
|
|
||||||
open={confirmDelete}
|
|
||||||
closeHandler={cancelDeleteHandler}
|
|
||||||
severity='warning'
|
|
||||||
icon={<QuestionMarkIcon />}
|
|
||||||
action={
|
|
||||||
<>
|
|
||||||
<Button
|
|
||||||
color='error'
|
|
||||||
variant='contained'
|
|
||||||
size='small'
|
|
||||||
onClick={deleteHandler}
|
|
||||||
>
|
|
||||||
{t('yes')}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
color='primary'
|
|
||||||
variant='outlined'
|
|
||||||
size='small'
|
|
||||||
onclick={cancelDeleteHandler}
|
|
||||||
>
|
|
||||||
{t('no')}
|
|
||||||
</Button>
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{t('deleteTrack')}
|
|
||||||
</Alert>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,299 +0,0 @@
|
||||||
import { createEffect, createRoot, createSignal } from 'solid-js';
|
|
||||||
import PouchDB from 'pouchdb';
|
|
||||||
import indexeddb from 'pouchdb-adapter-indexeddb';
|
|
||||||
|
|
||||||
import { sleep, until } from '../lib/async-wait';
|
|
||||||
import { isEqual } from 'lodash';
|
|
||||||
import { dbUrlToUserId } from '../lib/user-id';
|
|
||||||
|
|
||||||
PouchDB.plugin(indexeddb);
|
|
||||||
|
|
||||||
declare global {
|
|
||||||
var localDb: any;
|
|
||||||
var db: any;
|
|
||||||
var remoteDb: any;
|
|
||||||
var currentAccount: any;
|
|
||||||
var sync: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [state, setState] = createSignal<any>({});
|
|
||||||
export { state };
|
|
||||||
|
|
||||||
export const watchDbLegacy = async () => {
|
|
||||||
createRoot(async (dispose) => {
|
|
||||||
console.log({ caller: 'watchDbLegacy / start' });
|
|
||||||
|
|
||||||
const { db, localDb, remoteDb, sync, currentAccount } = globalThis;
|
|
||||||
|
|
||||||
const [status, setStatus] = createSignal<any>({});
|
|
||||||
const [syncState, setSyncState] = createSignal<any>({});
|
|
||||||
const [remoteUrl, setRemoteUrl] = createSignal<string>();
|
|
||||||
|
|
||||||
const updateStatus = async () => {
|
|
||||||
const dbInfo = await db.info();
|
|
||||||
const localDbInfo = await localDb.info();
|
|
||||||
const remoteDbInfo = remoteDb ? await remoteDb.info() : undefined;
|
|
||||||
const tasks = PouchDB.activeTasks.list();
|
|
||||||
const newStatus = {
|
|
||||||
...status(),
|
|
||||||
tasks,
|
|
||||||
dbInfo,
|
|
||||||
localDbInfo,
|
|
||||||
remoteDbInfo,
|
|
||||||
// date: new Date(),
|
|
||||||
};
|
|
||||||
if (!isEqual(status(), newStatus)) {
|
|
||||||
setStatus(newStatus);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
createEffect(() => {
|
|
||||||
console.log({
|
|
||||||
caller: 'watchDbLegacy',
|
|
||||||
state: state(),
|
|
||||||
status: status(),
|
|
||||||
syncState: syncState(),
|
|
||||||
sync,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
createEffect(() => {
|
|
||||||
const newState = {
|
|
||||||
...state(),
|
|
||||||
dbName: status()?.dbInfo?.db_name,
|
|
||||||
userId: dbUrlToUserId(status()?.remoteDbInfo?.host),
|
|
||||||
localUpdateSeq: status()?.dbInfo?.update_seq,
|
|
||||||
remoteUrl: status()?.remoteDbInfo?.host,
|
|
||||||
sync: syncState(),
|
|
||||||
};
|
|
||||||
if (!isEqual(newState, state())) {
|
|
||||||
setState(newState);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
updateStatus();
|
|
||||||
|
|
||||||
if (sync) {
|
|
||||||
sync
|
|
||||||
.on('change', function (info) {
|
|
||||||
// handle change
|
|
||||||
// console.log({ caller: 'Sync / change', info });
|
|
||||||
if (info.direction === 'push') {
|
|
||||||
setSyncState({ ...syncState(), lastSeq: info.change.last_seq });
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.on('paused', function (err) {
|
|
||||||
// replication paused (e.g. replication up to date, user went offline)
|
|
||||||
setSyncState({ ...syncState(), paused: true });
|
|
||||||
// console.log({ caller: 'Sync / paused', err });
|
|
||||||
})
|
|
||||||
.on('active', function () {
|
|
||||||
// replicate resumed (e.g. new changes replicating, user went back online)
|
|
||||||
setSyncState({ ...syncState(), paused: false });
|
|
||||||
// console.log({ caller: 'Sync / active' });
|
|
||||||
})
|
|
||||||
.on('denied', function (err) {
|
|
||||||
// a document failed to replicate (e.g. due to permissions)
|
|
||||||
console.error({ caller: 'Sync / denied', err });
|
|
||||||
})
|
|
||||||
.on('complete', function (info) {
|
|
||||||
// handle complete
|
|
||||||
console.log({ caller: 'Sync / complete', info });
|
|
||||||
})
|
|
||||||
.on('error', function (err) {
|
|
||||||
// handle error
|
|
||||||
console.error({ caller: 'Sync / error', err });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const timerId = setInterval(updateStatus, 15000);
|
|
||||||
|
|
||||||
const findDocumentsWithoutOrigin = async () => {
|
|
||||||
const allDocs = await db.allDocs({ include_docs: true });
|
|
||||||
return allDocs.rows
|
|
||||||
.filter(
|
|
||||||
(row: any) =>
|
|
||||||
!row.doc.origin || !row.doc.origin.match(/^@([^>]+)>(.+)$/)
|
|
||||||
)
|
|
||||||
.map((row: any) => row.doc._id);
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateDocumentsWithoutOrigin = async () => {
|
|
||||||
const documentsWithoutOrigin = await findDocumentsWithoutOrigin();
|
|
||||||
console.log({
|
|
||||||
caller: 'watchDbLegacy / addOrigin',
|
|
||||||
remoteUrl: state().remoteUrl,
|
|
||||||
nbDocumentsWithoutOrigin: documentsWithoutOrigin.length,
|
|
||||||
});
|
|
||||||
for (const docId of documentsWithoutOrigin) {
|
|
||||||
while (true) {
|
|
||||||
await sleep(100);
|
|
||||||
const doc = await db.get(docId);
|
|
||||||
console.log({
|
|
||||||
caller: 'watchDbLegacy / addOrigin',
|
|
||||||
remoteUrl: state().remoteUrl,
|
|
||||||
docId,
|
|
||||||
doc,
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
db.put({ ...doc, origin: dbUrlToUserId(state().remoteUrl) });
|
|
||||||
break;
|
|
||||||
} catch (error) {
|
|
||||||
if (error.name === 'conflict') {
|
|
||||||
console.log({
|
|
||||||
caller: 'watchDbLegacy / addOrigin',
|
|
||||||
docId,
|
|
||||||
doc,
|
|
||||||
error,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.error({
|
|
||||||
caller: 'watchDbLegacy / addOrigin',
|
|
||||||
docId,
|
|
||||||
doc,
|
|
||||||
error,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!!state().remoteUrl) {
|
|
||||||
await updateDocumentsWithoutOrigin();
|
|
||||||
}
|
|
||||||
|
|
||||||
createEffect(async () => {
|
|
||||||
if (!!state().remoteUrl && remoteUrl() !== state().remoteUrl) {
|
|
||||||
setRemoteUrl(state().remoteUrl);
|
|
||||||
// Check documents and update without origin
|
|
||||||
await updateDocumentsWithoutOrigin();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// db.compact();
|
|
||||||
const openIDb = (name: string) =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
const iDb = indexedDB.open(name);
|
|
||||||
iDb.onerror = (event: any) => {
|
|
||||||
console.error({
|
|
||||||
caller: 'watchDbLegacy',
|
|
||||||
message: 'open db error',
|
|
||||||
target: event.target,
|
|
||||||
});
|
|
||||||
reject(event.target.errorCode);
|
|
||||||
};
|
|
||||||
|
|
||||||
iDb.onsuccess = (event: any) => {
|
|
||||||
resolve(event.target.result);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const getAll = (store: any) =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
const request = store.getAll();
|
|
||||||
request.onerror = (event: any) => {
|
|
||||||
console.error({
|
|
||||||
caller: 'watchDbLegacy',
|
|
||||||
message: 'getAll error',
|
|
||||||
target: event.target,
|
|
||||||
});
|
|
||||||
reject(event.target.errorCode);
|
|
||||||
};
|
|
||||||
|
|
||||||
request.onsuccess = (event: any) => {
|
|
||||||
resolve(event.target.result as any[]);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const getDeletedDocs = async () => {
|
|
||||||
const iDb = (await openIDb(`_pouch_${state().dbName}`)) as IDBDatabase;
|
|
||||||
const bySequence = iDb.transaction('docs', 'readonly');
|
|
||||||
const store = bySequence.objectStore('docs');
|
|
||||||
const allDocs = (await getAll(store)) as any[];
|
|
||||||
iDb.close();
|
|
||||||
const docs = allDocs
|
|
||||||
.filter(
|
|
||||||
(doc) =>
|
|
||||||
!doc.id.startsWith('_local') &&
|
|
||||||
doc.deleted === 1 &&
|
|
||||||
doc.seq <= state()?.sync?.lastSeq
|
|
||||||
)
|
|
||||||
.map((doc) => ({ id: doc.id, rev: doc.rev }));
|
|
||||||
// console.log({
|
|
||||||
// caller: 'watchDbLegacy / getDeletedDocs',
|
|
||||||
// // bySequence,
|
|
||||||
// // store,
|
|
||||||
// // allDocs,
|
|
||||||
// docs,
|
|
||||||
// state: state(),gi
|
|
||||||
// });
|
|
||||||
return docs;
|
|
||||||
};
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
await until(
|
|
||||||
() => state()?.sync?.paused, //&&
|
|
||||||
//state()?.sync?.lastSeq >= state()?.localUpdateSeq - 1, // I wonder why this can happen !
|
|
||||||
1000
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log({ caller: 'watchDbLegacy / ready to purge after sync ' });
|
|
||||||
|
|
||||||
try {
|
|
||||||
const localPurges = await db.get('_local/purges');
|
|
||||||
localPurges._deleted = true;
|
|
||||||
await db.put(localPurges);
|
|
||||||
} catch (error) {
|
|
||||||
// console.warn({ caller: 'watchDbLegacy / _local/purges', error });
|
|
||||||
}
|
|
||||||
|
|
||||||
const deletedDocs = await getDeletedDocs();
|
|
||||||
|
|
||||||
let i = 0;
|
|
||||||
if (deletedDocs.length > 0) {
|
|
||||||
console.log({
|
|
||||||
caller: 'watchDbLegacy / purge',
|
|
||||||
// bySequence,
|
|
||||||
// store,
|
|
||||||
// allDocs,
|
|
||||||
deletedDocs,
|
|
||||||
state: state(),
|
|
||||||
});
|
|
||||||
for (const doc of deletedDocs) {
|
|
||||||
await sleep(10);
|
|
||||||
try {
|
|
||||||
await db.purge(doc.id, doc.rev);
|
|
||||||
} catch (err) {
|
|
||||||
console.log({
|
|
||||||
caller: 'watchDbLegacy / purge',
|
|
||||||
doc,
|
|
||||||
err,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
i = i + 1;
|
|
||||||
if (i % 10 === 0) {
|
|
||||||
console.log({
|
|
||||||
caller: 'watchDbLegacy / purge',
|
|
||||||
nbDeletedDocs: i,
|
|
||||||
nbDocsToDelete: deletedDocs.length,
|
|
||||||
doc,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (i === 1000) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log({
|
|
||||||
caller: 'watchDbLegacy / purge',
|
|
||||||
nbDeletedDocs: i,
|
|
||||||
nbDocsToDelete: deletedDocs.length,
|
|
||||||
});
|
|
||||||
if (i === deletedDocs.length) {
|
|
||||||
await sleep(60000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
|
@ -1,181 +0,0 @@
|
||||||
import { Signal } from 'solid-js';
|
|
||||||
import PouchDB from 'pouchdb';
|
|
||||||
import indexeddb from 'pouchdb-adapter-indexeddb';
|
|
||||||
|
|
||||||
import { sleep } from '../lib/async-wait';
|
|
||||||
import { openDatabases } from './open';
|
|
||||||
import { toHex } from '../lib/to-hex';
|
|
||||||
import { isEqual } from 'lodash';
|
|
||||||
|
|
||||||
PouchDB.plugin(indexeddb);
|
|
||||||
|
|
||||||
declare global {
|
|
||||||
var localDb: any;
|
|
||||||
var db: any;
|
|
||||||
var remoteDb: any;
|
|
||||||
var currentAccount: any;
|
|
||||||
var sync: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
const initDb = async () => {
|
|
||||||
if (globalThis.localDb === undefined) {
|
|
||||||
globalThis.currentAccount = await openDatabases();
|
|
||||||
const currentAccount = globalThis.currentAccount;
|
|
||||||
|
|
||||||
// if (currentAccount.remoteDbServer) {
|
|
||||||
// const url = `${currentAccount.remoteDbServer}/userdb-${toHex(
|
|
||||||
// currentAccount.remoteDbUser
|
|
||||||
// )}`;
|
|
||||||
|
|
||||||
// const remoteDb = new PouchDB(url, {
|
|
||||||
// auth: {
|
|
||||||
// username: currentAccount.remoteDbUser,
|
|
||||||
// password: currentAccount.remoteDbPassword,
|
|
||||||
// },
|
|
||||||
// skip_setup: true,
|
|
||||||
// });
|
|
||||||
// globalThis.remoteDb = remoteDb;
|
|
||||||
// globalThis.sync = PouchDB.sync(db, remoteDb, {
|
|
||||||
// live: true,
|
|
||||||
// retry: true,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const watchDb = async (p: { signal: Signal<any>; params: any }) => {
|
|
||||||
const { signal } = p;
|
|
||||||
const [status, setStatus] = signal;
|
|
||||||
console.log({ caller: 'watchDb', p });
|
|
||||||
|
|
||||||
await initDb();
|
|
||||||
db = globalThis.db;
|
|
||||||
localDb = globalThis.localDb;
|
|
||||||
|
|
||||||
setStatus({ opened: true });
|
|
||||||
|
|
||||||
// if (globalThis.sync) {
|
|
||||||
// globalThis.sync
|
|
||||||
// .on('change', function (info) {
|
|
||||||
// // handle change
|
|
||||||
// console.log({ caller: 'Sync / change', info });
|
|
||||||
// })
|
|
||||||
// .on('paused', function (err) {
|
|
||||||
// // replication paused (e.g. replication up to date, user went offline)
|
|
||||||
// console.log({ caller: 'Sync / paused', err });
|
|
||||||
// })
|
|
||||||
// .on('active', function () {
|
|
||||||
// // replicate resumed (e.g. new changes replicating, user went back online)
|
|
||||||
// console.log({ caller: 'Sync / active' });
|
|
||||||
// })
|
|
||||||
// .on('denied', function (err) {
|
|
||||||
// // a document failed to replicate (e.g. due to permissions)
|
|
||||||
// console.error({ caller: 'Sync / denied', err });
|
|
||||||
// })
|
|
||||||
// .on('complete', function (info) {
|
|
||||||
// // handle complete
|
|
||||||
// console.log({ caller: 'Sync / complete', info });
|
|
||||||
// })
|
|
||||||
// .on('error', function (err) {
|
|
||||||
// // handle error
|
|
||||||
// console.error({ caller: 'Sync / error', err });
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
const timerId = setInterval(async () => {
|
|
||||||
const dbInfo = await db.info();
|
|
||||||
const localDbInfo = await localDb.info();
|
|
||||||
const remoteDbInfo = globalThis.remoteDb
|
|
||||||
? await remoteDb.info()
|
|
||||||
: undefined;
|
|
||||||
const tasks = PouchDB.activeTasks.list();
|
|
||||||
const newStatus = {
|
|
||||||
...status(),
|
|
||||||
tasks,
|
|
||||||
dbInfo,
|
|
||||||
localDbInfo,
|
|
||||||
remoteDbInfo,
|
|
||||||
// date: new Date(),
|
|
||||||
};
|
|
||||||
if (!isEqual(status(), newStatus)) {
|
|
||||||
setStatus(newStatus);
|
|
||||||
}
|
|
||||||
}, 10000);
|
|
||||||
|
|
||||||
// db.compact();
|
|
||||||
|
|
||||||
await sleep(10000);
|
|
||||||
|
|
||||||
const openIDb = (name: string) =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
const iDb = indexedDB.open(name);
|
|
||||||
iDb.onerror = (event: any) => {
|
|
||||||
console.error({
|
|
||||||
caller: 'watchDb',
|
|
||||||
message: 'open db error',
|
|
||||||
target: event.target,
|
|
||||||
});
|
|
||||||
reject(event.target.errorCode);
|
|
||||||
};
|
|
||||||
|
|
||||||
iDb.onsuccess = (event: any) => {
|
|
||||||
console.log({
|
|
||||||
caller: 'watchDb',
|
|
||||||
message: 'open db',
|
|
||||||
target: event.target,
|
|
||||||
});
|
|
||||||
resolve(event.target.result);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const getAll = (store: any) =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
const request = store.getAll();
|
|
||||||
request.onerror = (event: any) => {
|
|
||||||
console.error({
|
|
||||||
caller: 'watchDb',
|
|
||||||
message: 'getAll error',
|
|
||||||
target: event.target,
|
|
||||||
});
|
|
||||||
reject(event.target.errorCode);
|
|
||||||
};
|
|
||||||
|
|
||||||
request.onsuccess = (event: any) => {
|
|
||||||
console.log({
|
|
||||||
caller: 'watchDb',
|
|
||||||
message: 'getAll',
|
|
||||||
target: event.target,
|
|
||||||
});
|
|
||||||
resolve(event.target.result as any[]);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
// const iDb = (await openIDb('_pouch__dyomedea_')) as IDBDatabase;
|
|
||||||
|
|
||||||
// const bySequence = iDb.transaction('docs', 'readonly');
|
|
||||||
// const store = bySequence.objectStore('docs');
|
|
||||||
// console.log({
|
|
||||||
// caller: 'watchDb',
|
|
||||||
// message: 'transaction opened',
|
|
||||||
// bySequence,
|
|
||||||
// store,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const docs = (await getAll(store)) as any[];
|
|
||||||
|
|
||||||
// docs.forEach(async (doc) => {
|
|
||||||
// const { id, rev, deleted } = doc;
|
|
||||||
// if (deleted !== 0) {
|
|
||||||
// // const purge = await db.purge(id, rev);
|
|
||||||
// console.log({
|
|
||||||
// caller: 'watchDb',
|
|
||||||
// message: 'purging',
|
|
||||||
// id,
|
|
||||||
// rev,
|
|
||||||
// doc,
|
|
||||||
// // purge,
|
|
||||||
// });
|
|
||||||
// await sleep(1000);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
};
|
|
|
@ -1,48 +0,0 @@
|
||||||
import PouchDB from 'pouchdb';
|
|
||||||
import indexeddb from 'pouchdb-adapter-indexeddb';
|
|
||||||
import {
|
|
||||||
getAccounts,
|
|
||||||
initialAccount,
|
|
||||||
putAccount,
|
|
||||||
getAccountById,
|
|
||||||
} from '../db/account';
|
|
||||||
import { getSettings, putSettings } from '../db/settings';
|
|
||||||
|
|
||||||
PouchDB.plugin(indexeddb);
|
|
||||||
|
|
||||||
declare global {
|
|
||||||
var localDb: any;
|
|
||||||
var db: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const openDatabases = async () => {
|
|
||||||
globalThis.localDb = new PouchDB('_local_dyomedea_', {
|
|
||||||
adapter: 'indexeddb',
|
|
||||||
auto_compaction: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const accounts = await getAccounts();
|
|
||||||
|
|
||||||
if (accounts.length === 0) {
|
|
||||||
accounts[0] = initialAccount;
|
|
||||||
await putAccount({ id: initialAccount.id, account: initialAccount });
|
|
||||||
}
|
|
||||||
|
|
||||||
const settings = await getSettings();
|
|
||||||
let currentAccount = getAccountById(accounts, settings.currentAccountId);
|
|
||||||
if (currentAccount === undefined) {
|
|
||||||
settings.currentAccountId = accounts[0].id;
|
|
||||||
await putSettings({ settings });
|
|
||||||
currentAccount = accounts[0];
|
|
||||||
}
|
|
||||||
console.log({ caller: 'open', accounts, settings });
|
|
||||||
|
|
||||||
if (globalThis.db === undefined) {
|
|
||||||
globalThis.db = new PouchDB(currentAccount.localDb, {
|
|
||||||
adapter: 'indexeddb',
|
|
||||||
auto_compaction: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return currentAccount;
|
|
||||||
};
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { get, getFamily, put } from './lib';
|
import { getFamily, put } from './lib';
|
||||||
import getUri from '../lib/ids';
|
import getUri from '../lib/ids';
|
||||||
import { getSettings, putSettings } from './settings';
|
|
||||||
|
|
||||||
export const initialAccount = {
|
export const initialAccount = {
|
||||||
id: 'initial',
|
id: 'initial',
|
||||||
name: '???',
|
name: '???',
|
||||||
localDb: '_dyomedea_',
|
localDb: 'dyomedea',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAccounts = async () => {
|
export const getAccounts = async () => {
|
||||||
|
@ -13,13 +12,6 @@ export const getAccounts = async () => {
|
||||||
return accountDocs.rows.map((row: any) => row.doc.doc);
|
return accountDocs.rows.map((row: any) => row.doc.doc);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAccount = async (params: any) => {
|
|
||||||
const { id } = params;
|
|
||||||
console.log({ caller: 'getAccount', params });
|
|
||||||
const uri = getUri('account', { account: id });
|
|
||||||
return (await get(uri, true)).doc;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const putAccount = async (params: any) => {
|
export const putAccount = async (params: any) => {
|
||||||
const { id, account } = params;
|
const { id, account } = params;
|
||||||
const uri = getUri('account', { account: id });
|
const uri = getUri('account', { account: id });
|
||||||
|
@ -30,14 +22,3 @@ export const getAccountById = (accounts: any, id: string) => {
|
||||||
const targetAccounts: any[] = accounts.filter((acc: any) => acc.id === id);
|
const targetAccounts: any[] = accounts.filter((acc: any) => acc.id === id);
|
||||||
return targetAccounts[0];
|
return targetAccounts[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCurrentAccount = async (params: any) => {
|
|
||||||
const settings = await getSettings();
|
|
||||||
return await getAccount({ id: settings.currentAccountId });
|
|
||||||
};
|
|
||||||
|
|
||||||
export const putCurrentAccount = async (params: any) => {
|
|
||||||
const { account } = params;
|
|
||||||
const settings = await getSettings();
|
|
||||||
await putAccount({ id: settings.currentAccountId, account });
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { debounce, slice } from 'lodash';
|
import { debounce, slice } from 'lodash';
|
||||||
import { getWpt } from '../db/wpt';
|
import { getWpt } from '../db/wpt';
|
||||||
import { getParentId } from '../lib/docuri';
|
|
||||||
import { returnAgain } from '../workers/dispatcher-worker';
|
import { returnAgain } from '../workers/dispatcher-worker';
|
||||||
import { getAllGpxes, getGpx } from './gpx';
|
import { getAllGpxes, getGpx } from './gpx';
|
||||||
import { put } from './lib';
|
import { put } from './lib';
|
||||||
|
@ -8,7 +7,6 @@ import { getOverlays } from './overlays';
|
||||||
import { getRte } from './rte';
|
import { getRte } from './rte';
|
||||||
import { getTrk } from './trk';
|
import { getTrk } from './trk';
|
||||||
import { getTrkseg } from './trkseg';
|
import { getTrkseg } from './trkseg';
|
||||||
import { getDrawingSelections } from './drawing-selections';
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
var watches: Map<string, any>;
|
var watches: Map<string, any>;
|
||||||
|
@ -22,20 +20,15 @@ const methods = {
|
||||||
getWpt,
|
getWpt,
|
||||||
getRte,
|
getRte,
|
||||||
getOverlays,
|
getOverlays,
|
||||||
getDrawingSelections,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendUpdate = async (params: any) => {
|
const sendUpdate = async (params: any) => {
|
||||||
if (params) {
|
if (params) {
|
||||||
console.log({ caller: 'ChangeHandler / sendUpdate', params });
|
console.log({ caller: 'ChangeHandler / sendUpdate', params });
|
||||||
try {
|
const { method, _dispatchId, id, ...otherParams } = params;
|
||||||
const { method, _dispatchId, id, ...otherParams } = params;
|
const returnValue = await methods[<keyof typeof methods>method](params);
|
||||||
const returnValue = await methods[<keyof typeof methods>method](params);
|
if (returnValue) {
|
||||||
if (returnValue) {
|
returnAgain(_dispatchId, returnValue);
|
||||||
returnAgain(_dispatchId, returnValue);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error({ caller: 'ChangeHandler / sendUpdate', params, error });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -50,24 +43,34 @@ for (const property in methods) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeHandler = async (change: any) => {
|
const changeHandler = async (change: any) => {
|
||||||
// console.log({ caller: 'ChangeHandler', change, watches: globalThis.watches });
|
console.log({ caller: 'ChangeHandler', change, watches: globalThis.watches });
|
||||||
const { id } = change;
|
const { id } = change;
|
||||||
if (!globalThis.watches) {
|
if (!globalThis.watches) {
|
||||||
globalThis.watches = new Map();
|
globalThis.watches = new Map();
|
||||||
}
|
}
|
||||||
sendUpdate(globalThis.watches.get(id));
|
sendUpdate(globalThis.watches.get(id));
|
||||||
|
|
||||||
const parentId = getParentId(id);
|
const tokens = id.split('/').slice(0, -1);
|
||||||
|
if (['1wpt', '2rte', '3trk'].includes(tokens.at(-1))) {
|
||||||
|
tokens.splice(-1);
|
||||||
|
}
|
||||||
|
const parentId = tokens.join('/');
|
||||||
|
console.log({
|
||||||
|
caller: 'ChangeHandler',
|
||||||
|
change,
|
||||||
|
watches: globalThis.watches,
|
||||||
|
parentId,
|
||||||
|
});
|
||||||
|
|
||||||
if (parentId === 'gpx') {
|
if (parentId === 'gpx') {
|
||||||
const gpxes = await getAllGpxes();
|
const gpxes = await getAllGpxes();
|
||||||
// console.log({ caller: 'changeHandler / gpxes', gpxes, id });
|
console.log({ caller: 'changeHandler / gpxes', gpxes, id });
|
||||||
if (!gpxes.includes(id)) {
|
if (!gpxes.includes(id)) {
|
||||||
await put(
|
await put(
|
||||||
parentId,
|
parentId,
|
||||||
`idx-${parentId}`,
|
`idx-${parentId}`,
|
||||||
(doc) => {
|
(doc) => {
|
||||||
// console.log({ caller: 'changeHandler / gpxes', doc });
|
console.log({ caller: 'changeHandler / gpxes', doc });
|
||||||
doc.push(id);
|
doc.push(id);
|
||||||
doc.reverse().sort().reverse();
|
doc.reverse().sort().reverse();
|
||||||
return doc;
|
return doc;
|
||||||
|
@ -86,23 +89,23 @@ const changeHandler = async (change: any) => {
|
||||||
export default changeHandler;
|
export default changeHandler;
|
||||||
|
|
||||||
export const getAndWatch = async (params: any) => {
|
export const getAndWatch = async (params: any) => {
|
||||||
// console.log({
|
console.log({
|
||||||
// caller: 'ChangeHandler / getAndWatch',
|
caller: 'ChangeHandler / getAndWatch',
|
||||||
// params,
|
params,
|
||||||
// watches: globalThis.watches,
|
watches: globalThis.watches,
|
||||||
// });
|
});
|
||||||
const { method, _dispatchId, id, ...otherParams } = params;
|
const { method, _dispatchId, id, ...otherParams } = params;
|
||||||
if (!globalThis.watches) {
|
if (!globalThis.watches) {
|
||||||
globalThis.watches = new Map();
|
globalThis.watches = new Map();
|
||||||
}
|
}
|
||||||
globalThis.watches.set(id, params);
|
globalThis.watches.set(id, params);
|
||||||
const returnValue = await methods[<keyof typeof methods>method](params);
|
const returnValue = await methods[<keyof typeof methods>method](params);
|
||||||
// console.log({
|
console.log({
|
||||||
// caller: 'ChangeHandler / getAndWatch',
|
caller: 'ChangeHandler / getAndWatch',
|
||||||
// params,
|
params,
|
||||||
// returnValue,
|
returnValue,
|
||||||
// watches: globalThis.watches,
|
watches: globalThis.watches,
|
||||||
// });
|
});
|
||||||
return returnValue;
|
return returnValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
import { get, put } from './lib';
|
|
||||||
|
|
||||||
export const getDrawingSelections = async (params: any) => {
|
|
||||||
const { id, defaultDrawingSelections } = params;
|
|
||||||
try {
|
|
||||||
const drawingSelections = await get(id, true);
|
|
||||||
return drawingSelections.doc;
|
|
||||||
} catch (error: any) {
|
|
||||||
console.error({ caller: 'defaultDrawingSelections', error });
|
|
||||||
return defaultDrawingSelections;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const putDrawingSelections = async (params: any) => {
|
|
||||||
const { id, drawingSelections } = params;
|
|
||||||
await put(id, 'drawingSelections', (doc) => drawingSelections, {}, true);
|
|
||||||
return drawingSelections;
|
|
||||||
};
|
|
|
@ -1,12 +1,5 @@
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { initDb } from '.';
|
||||||
import shell from 'shelljs';
|
|
||||||
|
|
||||||
import PouchDB from 'pouchdb';
|
|
||||||
|
|
||||||
import { existsGpx, putNewGpx } from './gpx';
|
import { existsGpx, putNewGpx } from './gpx';
|
||||||
|
|
||||||
const test = it;
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
var db: any;
|
var db: any;
|
||||||
var dbReady: boolean;
|
var dbReady: boolean;
|
||||||
|
@ -15,17 +8,16 @@ declare global {
|
||||||
const originalDb = globalThis.db;
|
const originalDb = globalThis.db;
|
||||||
const originalDateNow = globalThis.Date.now;
|
const originalDateNow = globalThis.Date.now;
|
||||||
|
|
||||||
describe('putNewGpx', () => {
|
describe('The gpx module', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
globalThis.db = { put: vi.fn() };
|
globalThis.db = { put: jest.fn() };
|
||||||
globalThis.Date.now = () => 0;
|
globalThis.Date.now = () => 0;
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
globalThis.db = originalDb;
|
globalThis.db = originalDb;
|
||||||
globalThis.Date.now = originalDateNow;
|
globalThis.Date.now = originalDateNow;
|
||||||
});
|
});
|
||||||
|
test('db.put() a new Gpx when required', async () => {
|
||||||
it('db.put() a new Gpx when required', async () => {
|
|
||||||
await putNewGpx({ gpx: 0 });
|
await putNewGpx({ gpx: 0 });
|
||||||
expect(globalThis.db.put).toBeCalledWith({
|
expect(globalThis.db.put).toBeCalledWith({
|
||||||
_id: 'gpx/0000000000000000',
|
_id: 'gpx/0000000000000000',
|
||||||
|
@ -64,24 +56,20 @@ describe('putNewGpx', () => {
|
||||||
type: 'gpx',
|
type: 'gpx',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
test('db.put() generates an id if needed', async () => {
|
||||||
|
const id = await putNewGpx();
|
||||||
|
expect(id).toEqual({ gpx: 4320000000000000 });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('The gpx module with a real db', () => {
|
describe('The gpx module with a real db', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
globalThis.db = new PouchDB('dyomedea', {
|
await initDb({});
|
||||||
auto_compaction: false,
|
|
||||||
});
|
|
||||||
globalThis.Date.now = () => 0;
|
globalThis.Date.now = () => 0;
|
||||||
});
|
});
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
try {
|
await db.destroy();
|
||||||
await db.destroy();
|
db = undefined;
|
||||||
} catch (err) {
|
|
||||||
// console.error(err);
|
|
||||||
await shell.exec('rm -rf $*$');
|
|
||||||
}
|
|
||||||
globalThis.db = undefined;
|
|
||||||
globalThis.dbReady = false;
|
|
||||||
globalThis.Date.now = originalDateNow;
|
globalThis.Date.now = originalDateNow;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
230
src/db/gpx.ts
|
@ -1,13 +1,10 @@
|
||||||
import { Rowing } from '@suid/icons-material';
|
|
||||||
import { cloneDeep, isEmpty } from 'lodash';
|
import { cloneDeep, isEmpty } from 'lodash';
|
||||||
import { PureComponent } from 'react';
|
import { PureComponent } from 'react';
|
||||||
import { $DEVCOMP } from 'solid-js';
|
import { $DEVCOMP } from 'solid-js';
|
||||||
import { Point, Rectangle } from '../components/map/types';
|
import { Point, Rectangle } from '../components/map/types';
|
||||||
import { state } from '../db-admin/health-legacy';
|
|
||||||
import { lat2tile, lon2tile, rectanglesIntersect } from '../lib/geo';
|
import { lat2tile, lon2tile, rectanglesIntersect } from '../lib/geo';
|
||||||
import { findStartTime } from '../lib/gpx';
|
import { findStartTime } from '../lib/gpx';
|
||||||
import getUri, { intToGpxId, intToTrkptId } from '../lib/ids';
|
import getUri, { intToGpxId, intToTrkptId } from '../lib/ids';
|
||||||
import { dbUrlToUserId } from '../lib/user-id';
|
|
||||||
import { get, getDocsByType, getFamily, put, putAll } from './lib';
|
import { get, getDocsByType, getFamily, put, putAll } from './lib';
|
||||||
|
|
||||||
export const emptyGpx: Gpx = {
|
export const emptyGpx: Gpx = {
|
||||||
|
@ -80,23 +77,22 @@ const prune = (
|
||||||
trkpt: number;
|
trkpt: number;
|
||||||
},
|
},
|
||||||
extensions: any,
|
extensions: any,
|
||||||
docs: any[],
|
docs: any[]
|
||||||
to: string[]
|
|
||||||
) => {
|
) => {
|
||||||
if (typeof object === 'object') {
|
if (typeof object === 'object') {
|
||||||
for (const key in object) {
|
for (const key in object) {
|
||||||
if (
|
if (
|
||||||
key === 'wpt' ||
|
key === 'wpt' ||
|
||||||
key === 'rte' ||
|
key === 'rte' ||
|
||||||
// key === 'rtept' ||
|
key === 'rtept' ||
|
||||||
key === 'trk' ||
|
key === 'trk' ||
|
||||||
key === 'trkseg'
|
key === 'trkseg' ||
|
||||||
// key === 'trkpt'
|
key === 'trkpt'
|
||||||
) {
|
) {
|
||||||
const subObjects = object[key];
|
const subObjects = object[key];
|
||||||
for (const index in subObjects) {
|
for (const index in subObjects) {
|
||||||
const subId = { ...id };
|
const subId = { ...id };
|
||||||
/* if (key === 'trkpt') {
|
if (key === 'trkpt') {
|
||||||
// fix buggy times in GPX tracks
|
// fix buggy times in GPX tracks
|
||||||
const normalId = intToTrkptId(
|
const normalId = intToTrkptId(
|
||||||
new Date(object[key][index].time).valueOf()
|
new Date(object[key][index].time).valueOf()
|
||||||
|
@ -105,10 +101,10 @@ const prune = (
|
||||||
normalId > previousIds.trk ? normalId : previousIds.trk + 1;
|
normalId > previousIds.trk ? normalId : previousIds.trk + 1;
|
||||||
subId[key] = id;
|
subId[key] = id;
|
||||||
previousIds.trk = id;
|
previousIds.trk = id;
|
||||||
} else { */
|
} else {
|
||||||
previousIds[key] = previousIds[key] + 1;
|
previousIds[key] = previousIds[key] + 1;
|
||||||
subId[key] = previousIds[key];
|
subId[key] = previousIds[key];
|
||||||
/* } */
|
}
|
||||||
// console.log({
|
// console.log({
|
||||||
// caller: 'prune',
|
// caller: 'prune',
|
||||||
// id,
|
// id,
|
||||||
|
@ -127,18 +123,94 @@ const prune = (
|
||||||
docs.push({
|
docs.push({
|
||||||
_id: getUri(key, subId),
|
_id: getUri(key, subId),
|
||||||
type: key,
|
type: key,
|
||||||
to,
|
|
||||||
origin: dbUrlToUserId(state().remoteUrl),
|
|
||||||
doc: subObjects[index],
|
doc: subObjects[index],
|
||||||
});
|
});
|
||||||
prune(subId, subObjects[index], previousIds, {}, docs, to);
|
prune(subId, subObjects[index], previousIds, {}, docs);
|
||||||
}
|
}
|
||||||
object[key] = undefined;
|
object[key] = undefined;
|
||||||
} else prune(id, object[key], previousIds, extensions, docs, to);
|
} else prune(id, object[key], previousIds, extensions, docs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// const extensionsFromObject = (
|
||||||
|
// object: any,
|
||||||
|
// extensions = {
|
||||||
|
// viewport: { topLeft: <Point>{}, bottomRight: <Point>{} },
|
||||||
|
// bbox: {
|
||||||
|
// minLon: <number | undefined>undefined,
|
||||||
|
// minLat: <number | undefined>undefined,
|
||||||
|
// maxLon: <number | undefined>undefined,
|
||||||
|
// maxLat: <number | undefined>undefined,
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
// ) => {
|
||||||
|
// if (typeof object === 'object') {
|
||||||
|
// if ('$' in object) {
|
||||||
|
// const attributes = object.$;
|
||||||
|
// if ('lat' in attributes) {
|
||||||
|
// const lat = +attributes.lat;
|
||||||
|
// if (
|
||||||
|
// extensions.bbox.minLat === undefined ||
|
||||||
|
// lat < extensions.bbox.minLat
|
||||||
|
// ) {
|
||||||
|
// extensions.bbox.minLat = lat;
|
||||||
|
// }
|
||||||
|
// if (
|
||||||
|
// extensions.bbox.maxLat === undefined ||
|
||||||
|
// lat > extensions.bbox.maxLat
|
||||||
|
// ) {
|
||||||
|
// extensions.bbox.maxLat = lat;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if ('lon' in attributes) {
|
||||||
|
// const lon = +attributes.lon;
|
||||||
|
// if (
|
||||||
|
// extensions.bbox.minLon === undefined ||
|
||||||
|
// lon < extensions.bbox.minLon
|
||||||
|
// ) {
|
||||||
|
// extensions.bbox.minLon = lon;
|
||||||
|
// }
|
||||||
|
// if (
|
||||||
|
// extensions.bbox.maxLon === undefined ||
|
||||||
|
// lon > extensions.bbox.maxLon
|
||||||
|
// ) {
|
||||||
|
// extensions.bbox.maxLon = lon;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// for (const key in object) {
|
||||||
|
// extensionsFromObject(object[key], extensions);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return extensions;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// const extensionsFromGpx = (gpx: Gpx) => {
|
||||||
|
// const extensions = { ...gpx.extensions, ...extensionsFromObject(gpx) };
|
||||||
|
// gpx.extensions = undefined;
|
||||||
|
// if (
|
||||||
|
// extensions.bbox.maxLat !== undefined &&
|
||||||
|
// extensions.bbox.minLon !== undefined
|
||||||
|
// ) {
|
||||||
|
// extensions.viewport.topLeft = {
|
||||||
|
// x: lon2tile(extensions.bbox.minLon, 0),
|
||||||
|
// y: lat2tile(extensions.bbox.maxLat, 0),
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
// if (
|
||||||
|
// extensions.bbox.minLat !== undefined &&
|
||||||
|
// extensions.bbox.maxLon !== undefined
|
||||||
|
// ) {
|
||||||
|
// extensions.viewport.bottomRight = {
|
||||||
|
// x: lon2tile(extensions.bbox.maxLon, 0),
|
||||||
|
// y: lat2tile(extensions.bbox.minLat, 0),
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return extensions;
|
||||||
|
// };
|
||||||
|
|
||||||
const hasMissingTimestamps = (trk: Trk) => {
|
const hasMissingTimestamps = (trk: Trk) => {
|
||||||
for (const trkseg of trk.trkseg!) {
|
for (const trkseg of trk.trkseg!) {
|
||||||
for (const trkpt of trkseg.trkpt!) {
|
for (const trkpt of trkseg.trkpt!) {
|
||||||
|
@ -150,13 +222,13 @@ const hasMissingTimestamps = (trk: Trk) => {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const convertTrkToRteWhenNeeded = (gpx: Gpx, forceImportAsRoutes: boolean) => {
|
const convertTrkToRteWhenNeeded = (gpx: Gpx) => {
|
||||||
if (gpx.trk === undefined) {
|
if (gpx.trk === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const newTrks: Trk[] = [];
|
const newTrks: Trk[] = [];
|
||||||
for (const trk of gpx.trk) {
|
for (const trk of gpx.trk) {
|
||||||
if (forceImportAsRoutes || hasMissingTimestamps(trk)) {
|
if (hasMissingTimestamps(trk)) {
|
||||||
const rte = { ...trk, trkseg: undefined, rtept: [] };
|
const rte = { ...trk, trkseg: undefined, rtept: [] };
|
||||||
for (const trkseg of trk.trkseg!) {
|
for (const trkseg of trk.trkseg!) {
|
||||||
rte.rtept = rte.rtept.concat(trkseg.trkpt);
|
rte.rtept = rte.rtept.concat(trkseg.trkpt);
|
||||||
|
@ -174,7 +246,7 @@ const convertTrkToRteWhenNeeded = (gpx: Gpx, forceImportAsRoutes: boolean) => {
|
||||||
|
|
||||||
export const pruneAndSaveImportedGpx = async (params: any) => {
|
export const pruneAndSaveImportedGpx = async (params: any) => {
|
||||||
console.log({ caller: 'pruneAndSaveImportedGpx', params });
|
console.log({ caller: 'pruneAndSaveImportedGpx', params });
|
||||||
const { id, gpx, tech, forceImportAsRoutes } = params;
|
const { id, gpx, tech } = params;
|
||||||
let gpxId: IdGpx;
|
let gpxId: IdGpx;
|
||||||
let docs: any[] = [];
|
let docs: any[] = [];
|
||||||
const extensions = {
|
const extensions = {
|
||||||
|
@ -186,9 +258,8 @@ export const pruneAndSaveImportedGpx = async (params: any) => {
|
||||||
extensions: gpx.extensions,
|
extensions: gpx.extensions,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
convertTrkToRteWhenNeeded(gpx, forceImportAsRoutes);
|
convertTrkToRteWhenNeeded(gpx);
|
||||||
let previousGpx: Gpx | null = null;
|
let previousGpx: Gpx | null = null;
|
||||||
let to: string[];
|
|
||||||
if (id === 'new') {
|
if (id === 'new') {
|
||||||
const currentDateTime = new Date().toISOString();
|
const currentDateTime = new Date().toISOString();
|
||||||
const startTime = new Date(findStartTime(gpx, currentDateTime));
|
const startTime = new Date(findStartTime(gpx, currentDateTime));
|
||||||
|
@ -200,26 +271,16 @@ export const pruneAndSaveImportedGpx = async (params: any) => {
|
||||||
}
|
}
|
||||||
gpxId = { gpx: intToGpxId(startTime.valueOf()) };
|
gpxId = { gpx: intToGpxId(startTime.valueOf()) };
|
||||||
docs = [
|
docs = [
|
||||||
{
|
{ _id: getUri('gpx', gpxId), type: 'gpx', doc: gpx },
|
||||||
_id: getUri('gpx', gpxId),
|
|
||||||
type: 'gpx',
|
|
||||||
origin: dbUrlToUserId(state().remoteUrl),
|
|
||||||
doc: gpx,
|
|
||||||
// a new GPX isn't to...
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
_id: getUri('extensions', gpxId),
|
_id: getUri('extensions', gpxId),
|
||||||
type: 'extensions',
|
type: 'extensions',
|
||||||
origin: dbUrlToUserId(state().remoteUrl),
|
|
||||||
doc: {},
|
doc: {},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
gpxId = getUri('gpx', id);
|
gpxId = getUri('gpx', id);
|
||||||
previousGpx = (await getGpx({ id })) ?? null;
|
previousGpx = (await getGpx({ id })) ?? null;
|
||||||
if (previousGpx?.extensions?.to) {
|
|
||||||
to = previousGpx?.extensions?.to.split(/\s*,\s*/);
|
|
||||||
}
|
|
||||||
console.log({
|
console.log({
|
||||||
caller: 'pruneAndSaveImportedGpx / previousGpx',
|
caller: 'pruneAndSaveImportedGpx / previousGpx',
|
||||||
id,
|
id,
|
||||||
|
@ -250,7 +311,7 @@ export const pruneAndSaveImportedGpx = async (params: any) => {
|
||||||
const trkId = getUri('trk', trkUri);
|
const trkId = getUri('trk', trkUri);
|
||||||
previousIds.trk = trkId.trk;
|
previousIds.trk = trkId.trk;
|
||||||
}
|
}
|
||||||
prune(gpxId, gpx, previousIds, extensions, docs, to);
|
prune(gpxId, gpx, previousIds, extensions, docs);
|
||||||
console.log({ caller: 'pruneAndSaveImportedGpx / pruned', docs });
|
console.log({ caller: 'pruneAndSaveImportedGpx / pruned', docs });
|
||||||
try {
|
try {
|
||||||
const result = await putAll(docs);
|
const result = await putAll(docs);
|
||||||
|
@ -362,20 +423,9 @@ export const getGpx = async (params: any) => {
|
||||||
}
|
}
|
||||||
//level 1 (extensions)
|
//level 1 (extensions)
|
||||||
if (target !== undefined && row.doc.type === 'extensions') {
|
if (target !== undefined && row.doc.type === 'extensions') {
|
||||||
console.log({
|
target.splice(1);
|
||||||
caller: 'getGpx / extensions',
|
appendToArray(target.at(-1), row.doc.type, row.doc.doc);
|
||||||
gpx,
|
target.push(row.doc.doc);
|
||||||
row,
|
|
||||||
doc: row.doc.doc,
|
|
||||||
gpx_extensions: gpx?.extensions,
|
|
||||||
target,
|
|
||||||
});
|
|
||||||
|
|
||||||
gpx.extensions = row.doc.doc;
|
|
||||||
|
|
||||||
// target.splice(1);
|
|
||||||
// appendToArray(target.at(-1), row.doc.type, row.doc.doc);
|
|
||||||
// target.push(row.doc.doc);
|
|
||||||
}
|
}
|
||||||
//level 1 (others)
|
//level 1 (others)
|
||||||
if (
|
if (
|
||||||
|
@ -421,72 +471,28 @@ export const appendTrk = async (params: any) => {
|
||||||
export const putGpx = async (params: any) => {
|
export const putGpx = async (params: any) => {
|
||||||
let { id, gpx } = params;
|
let { id, gpx } = params;
|
||||||
|
|
||||||
try {
|
if (id === 'new') {
|
||||||
if (id === 'new' || !id) {
|
const date = !!gpx.metadata.time ? new Date(gpx.metadata.time) : new Date();
|
||||||
const date = !!gpx.metadata.time
|
id = getUri('gpx', {
|
||||||
? new Date(gpx.metadata.time)
|
gpx: intToGpxId(date.valueOf()),
|
||||||
: new Date();
|
|
||||||
id = getUri('gpx', {
|
|
||||||
gpx: intToGpxId(date.valueOf()),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let previousTo;
|
|
||||||
try {
|
|
||||||
previousTo = (await get(`${id}/4extensions`)).doc?.to;
|
|
||||||
} catch (error) {}
|
|
||||||
|
|
||||||
console.log({ caller: 'putGpx', params, id, gpx, previousTo });
|
|
||||||
const extensions = gpx?.extensions;
|
|
||||||
|
|
||||||
gpx.extensions = undefined;
|
|
||||||
gpx.wpt = undefined;
|
|
||||||
gpx.trk = undefined;
|
|
||||||
gpx.rte = undefined;
|
|
||||||
|
|
||||||
await put(id, 'gpx', (doc) => gpx, gpx);
|
|
||||||
if (extensions !== undefined) {
|
|
||||||
try {
|
|
||||||
await put(
|
|
||||||
`${id}/4extensions`,
|
|
||||||
'extensions',
|
|
||||||
(doc) => extensions,
|
|
||||||
extensions
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
console.error({
|
|
||||||
caller: 'putGpx / extensions',
|
|
||||||
error,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (previousTo !== extensions?.to) {
|
|
||||||
const to = extensions?.to.split(/\s*,\s*/);
|
|
||||||
const family = (await getFamily(id, { include_docs: true })).rows.map(
|
|
||||||
(row: any) => {
|
|
||||||
return { ...row.doc, to };
|
|
||||||
}
|
|
||||||
);
|
|
||||||
console.log({
|
|
||||||
caller: 'putGpx / updateTo',
|
|
||||||
params,
|
|
||||||
id,
|
|
||||||
gpx,
|
|
||||||
previousTo,
|
|
||||||
family,
|
|
||||||
});
|
|
||||||
await db.bulkDocs(family);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error({
|
|
||||||
caller: 'putGpx',
|
|
||||||
params,
|
|
||||||
id,
|
|
||||||
gpx,
|
|
||||||
error,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
console.log({ caller: 'putGpx', params, id, gpx });
|
||||||
|
const extensions = gpx?.extensions;
|
||||||
|
|
||||||
|
gpx.extensions = undefined;
|
||||||
|
gpx.wpt = undefined;
|
||||||
|
gpx.trk = undefined;
|
||||||
|
gpx.rte = undefined;
|
||||||
|
|
||||||
|
await put(id, 'gpx', (doc) => gpx, gpx);
|
||||||
|
if (extensions !== undefined) {
|
||||||
|
await put(
|
||||||
|
`${id}/4extensions`,
|
||||||
|
'extensions',
|
||||||
|
(doc) => extensions,
|
||||||
|
extensions
|
||||||
|
);
|
||||||
|
}
|
||||||
return id;
|
return id;
|
||||||
};
|
};
|
||||||
|
|
227
src/db/index.ts
|
@ -1,105 +1,154 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import PouchDB from 'pouchdb';
|
import PouchDB from 'pouchdb';
|
||||||
import { watchDbLegacy } from '../db-admin/health-legacy';
|
import uri from '../lib/ids';
|
||||||
import { openDatabases } from '../db-admin/open';
|
|
||||||
import { toHex } from '../lib/to-hex';
|
import { toHex } from '../lib/to-hex';
|
||||||
|
import {
|
||||||
|
getAccountById,
|
||||||
|
getAccounts,
|
||||||
|
initialAccount,
|
||||||
|
putAccount,
|
||||||
|
} from './account';
|
||||||
import changeHandler from './change-handler';
|
import changeHandler from './change-handler';
|
||||||
|
import { getSettings, putSettings } from './settings';
|
||||||
|
|
||||||
|
const dbDefinitionId = uri('dbdef', {});
|
||||||
|
|
||||||
|
const currentDbDefinition = {
|
||||||
|
_id: dbDefinitionId,
|
||||||
|
type: dbDefinitionId,
|
||||||
|
def: { version: '0.000001' },
|
||||||
|
};
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
var localDb: any;
|
var localDb: any;
|
||||||
var db: any;
|
var db: any;
|
||||||
var dbReady: boolean;
|
var dbReady: boolean;
|
||||||
var currentAccount: any;
|
|
||||||
var sync: any;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const initDb = async () => {
|
export const initDb = async (params: any) => {
|
||||||
console.log({ caller: 'initDb' });
|
console.log({ caller: 'initDb' });
|
||||||
|
|
||||||
if (globalThis.localDb === undefined) {
|
if (globalThis.localDb === undefined) {
|
||||||
globalThis.dbReady = false;
|
globalThis.localDb = new PouchDB('$local_dyomedea$', {
|
||||||
|
auto_compaction: true,
|
||||||
await openDatabases();
|
revs_limit: 10,
|
||||||
|
});
|
||||||
globalThis.currentAccount = await openDatabases();
|
|
||||||
const currentAccount = globalThis.currentAccount;
|
|
||||||
|
|
||||||
if (currentAccount.remoteDbServer) {
|
|
||||||
const url = `${currentAccount.remoteDbServer}/userdb-${toHex(
|
|
||||||
currentAccount.remoteDbUser
|
|
||||||
)}`;
|
|
||||||
|
|
||||||
const remoteDb = new PouchDB(url, {
|
|
||||||
auth: {
|
|
||||||
username: currentAccount.remoteDbUser,
|
|
||||||
password: currentAccount.remoteDbPassword,
|
|
||||||
},
|
|
||||||
skip_setup: true,
|
|
||||||
});
|
|
||||||
globalThis.remoteDb = remoteDb;
|
|
||||||
globalThis.sync = PouchDB.sync(db, remoteDb, {
|
|
||||||
live: true,
|
|
||||||
retry: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (globalThis.sync) {
|
|
||||||
// globalThis.sync
|
|
||||||
// .on('change', function (info) {
|
|
||||||
// // handle change
|
|
||||||
// console.log({ caller: 'Sync / change', info });
|
|
||||||
// })
|
|
||||||
// .on('paused', function (err) {
|
|
||||||
// // replication paused (e.g. replication up to date, user went offline)
|
|
||||||
// console.log({ caller: 'Sync / paused', err });
|
|
||||||
// })
|
|
||||||
// .on('active', function () {
|
|
||||||
// // replicate resumed (e.g. new changes replicating, user went back online)
|
|
||||||
// console.log({ caller: 'Sync / active' });
|
|
||||||
// })
|
|
||||||
// .on('denied', function (err) {
|
|
||||||
// // a document failed to replicate (e.g. due to permissions)
|
|
||||||
// console.error({ caller: 'Sync / denied', err });
|
|
||||||
// })
|
|
||||||
// .on('complete', function (info) {
|
|
||||||
// // handle complete
|
|
||||||
// console.log({ caller: 'Sync / complete', info });
|
|
||||||
// })
|
|
||||||
// .on('error', function (err) {
|
|
||||||
// // handle error
|
|
||||||
// console.error({ caller: 'Sync / error', err });
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// console.log({ caller: 'initDb / before db.changes' });
|
|
||||||
|
|
||||||
const changes = db
|
|
||||||
.changes({ since: 'now', live: true, include_docs: false })
|
|
||||||
.on('change', changeHandler)
|
|
||||||
.on('complete', (info: any) => {
|
|
||||||
console.log({ caller: 'changes / complete', info });
|
|
||||||
})
|
|
||||||
.on('error', (error: any) => {
|
|
||||||
console.log({ caller: 'changes / complete', error });
|
|
||||||
});
|
|
||||||
|
|
||||||
const localDbChanges = localDb
|
|
||||||
.changes({ since: 'now', live: true, include_docs: false })
|
|
||||||
.on('change', changeHandler)
|
|
||||||
.on('complete', (info: any) => {
|
|
||||||
console.log({ caller: 'localDb changes / complete', info });
|
|
||||||
})
|
|
||||||
.on('error', (error: any) => {
|
|
||||||
console.log({ caller: 'localDb changes / complete', error });
|
|
||||||
});
|
|
||||||
|
|
||||||
// console.log({ caller: 'initDb / back from db.changes', changes });
|
|
||||||
|
|
||||||
// changes.cancel();
|
|
||||||
|
|
||||||
globalThis.dbReady = true;
|
|
||||||
watchDbLegacy();
|
|
||||||
console.log({ caller: 'initDb / done' });
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const accounts = await getAccounts();
|
||||||
|
console.log({ caller: 'initDb', accounts });
|
||||||
|
|
||||||
|
if (accounts.length === 0) {
|
||||||
|
accounts[0] = initialAccount;
|
||||||
|
await putAccount({ id: initialAccount.id, account: initialAccount });
|
||||||
|
}
|
||||||
|
|
||||||
|
const settings = await getSettings();
|
||||||
|
let currentAccount = getAccountById(accounts, settings.currentAccountId);
|
||||||
|
if (currentAccount === undefined) {
|
||||||
|
settings.currentAccountId = accounts[0].id;
|
||||||
|
await putSettings({ settings });
|
||||||
|
currentAccount = accounts[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log({ caller: 'initDb', settings, currentAccount });
|
||||||
|
|
||||||
|
if (globalThis.db === undefined) {
|
||||||
|
globalThis.db = new PouchDB(currentAccount.localDb, {
|
||||||
|
auto_compaction: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const db = globalThis.db;
|
||||||
|
var previousDbDefinition = {
|
||||||
|
_id: dbDefinitionId,
|
||||||
|
type: dbDefinitionId,
|
||||||
|
def: { version: '0' },
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
previousDbDefinition = await db.get(dbDefinitionId);
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error.status !== 404) {
|
||||||
|
console.log(
|
||||||
|
`Unexpected error fetching db definition: ${JSON.stringify(error)}`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previousDbDefinition.def.version < currentDbDefinition.def.version) {
|
||||||
|
previousDbDefinition.def = currentDbDefinition.def;
|
||||||
|
db.put(previousDbDefinition);
|
||||||
|
// TODO: support migrations
|
||||||
|
}
|
||||||
|
//await await db.compact();
|
||||||
|
|
||||||
|
if (currentAccount.remoteDbServer) {
|
||||||
|
const url = `${currentAccount.remoteDbServer}/userdb-${toHex(
|
||||||
|
currentAccount.remoteDbUser
|
||||||
|
)}`;
|
||||||
|
|
||||||
|
const remoteDb = new PouchDB(url, {
|
||||||
|
auth: {
|
||||||
|
username: currentAccount.remoteDbUser,
|
||||||
|
password: currentAccount.remoteDbPassword,
|
||||||
|
},
|
||||||
|
skip_setup: true,
|
||||||
|
});
|
||||||
|
const sync = PouchDB.sync(db, remoteDb, {
|
||||||
|
live: true,
|
||||||
|
retry: true,
|
||||||
|
})
|
||||||
|
.on('change', function (info) {
|
||||||
|
// handle change
|
||||||
|
console.log({ caller: 'Sync / change', info });
|
||||||
|
})
|
||||||
|
.on('paused', function (err) {
|
||||||
|
// replication paused (e.g. replication up to date, user went offline)
|
||||||
|
console.log({ caller: 'Sync / paused', err });
|
||||||
|
})
|
||||||
|
.on('active', function () {
|
||||||
|
// replicate resumed (e.g. new changes replicating, user went back online)
|
||||||
|
console.log({ caller: 'Sync / active' });
|
||||||
|
})
|
||||||
|
.on('denied', function (err) {
|
||||||
|
// a document failed to replicate (e.g. due to permissions)
|
||||||
|
console.error({ caller: 'Sync / denied', err });
|
||||||
|
})
|
||||||
|
.on('complete', function (info) {
|
||||||
|
// handle complete
|
||||||
|
console.log({ caller: 'Sync / complete', info });
|
||||||
|
})
|
||||||
|
.on('error', function (err) {
|
||||||
|
// handle error
|
||||||
|
console.error({ caller: 'Sync / error', err });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log({ caller: 'initDb / before db.changes' });
|
||||||
|
|
||||||
|
const changes = db
|
||||||
|
.changes({ since: 'now', live: true, include_docs: false })
|
||||||
|
.on('change', changeHandler)
|
||||||
|
.on('complete', (info: any) => {
|
||||||
|
console.log({ caller: 'changes / complete', info });
|
||||||
|
})
|
||||||
|
.on('error', (error: any) => {
|
||||||
|
console.log({ caller: 'changes / complete', error });
|
||||||
|
});
|
||||||
|
|
||||||
|
const localDbChanges = localDb
|
||||||
|
.changes({ since: 'now', live: true, include_docs: false })
|
||||||
|
.on('change', changeHandler)
|
||||||
|
.on('complete', (info: any) => {
|
||||||
|
console.log({ caller: 'localDb changes / complete', info });
|
||||||
|
})
|
||||||
|
.on('error', (error: any) => {
|
||||||
|
console.log({ caller: 'localDb changes / complete', error });
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.log({ caller: 'initDb / back from db.changes', changes });
|
||||||
|
|
||||||
|
// changes.cancel();
|
||||||
|
|
||||||
|
globalThis.dbReady = true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,299 @@
|
||||||
|
import { initDb } from '.';
|
||||||
|
import uri from '../lib/ids';
|
||||||
|
import { getDocsByType, getFamily } from './lib';
|
||||||
|
import { putNewRte } from './rte';
|
||||||
|
import { putNewRtept } from './rtept';
|
||||||
|
import { putNewTrk } from './trk';
|
||||||
|
import { putNewTrkpt } from './trkpt';
|
||||||
|
import { putNewTrkseg } from './trkseg';
|
||||||
|
import { putNewWpt } from './wpt';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
var db: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
const originalDateNow = globalThis.Date.now;
|
||||||
|
|
||||||
|
describe('getFamily', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await initDb({});
|
||||||
|
globalThis.Date.now = () => 0;
|
||||||
|
});
|
||||||
|
afterEach(async () => {
|
||||||
|
await db.destroy();
|
||||||
|
db = undefined;
|
||||||
|
globalThis.Date.now = originalDateNow;
|
||||||
|
});
|
||||||
|
test('returns two rows after a gpx and a track have been inserted.', async () => {
|
||||||
|
await putNewTrk();
|
||||||
|
const allDocs: any = await getFamily('gpx/');
|
||||||
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"offset": 0,
|
||||||
|
"rows": Array [
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000",
|
||||||
|
"key": "gpx/4320000000000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000/3trk/000000",
|
||||||
|
"key": "gpx/4320000000000000/3trk/000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-4c114f3ae0073151e4082ff1d220c2a4",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"total_rows": 4,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
test('also returns the docs if required.', async () => {
|
||||||
|
await putNewTrk();
|
||||||
|
const allDocs: any = await getFamily('gpx/', {
|
||||||
|
include_docs: true,
|
||||||
|
});
|
||||||
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"offset": 0,
|
||||||
|
"rows": Array [
|
||||||
|
Object {
|
||||||
|
"doc": Object {
|
||||||
|
"_id": "gpx/4320000000000000",
|
||||||
|
"_rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||||
|
"doc": Object {
|
||||||
|
"$": Object {
|
||||||
|
"creator": "dyomedea version 0.000002",
|
||||||
|
"version": "1.1",
|
||||||
|
"xmlns": "http://www.topografix.com/GPX/1/1",
|
||||||
|
"xmlns:dyo": "http://xmlns.dyomedea.com/",
|
||||||
|
"xmlns:gpxtpx": "http://www.garmin.com/xmlschemas/TrackPointExtension/v1",
|
||||||
|
"xmlns:gpxx": "http://www.garmin.com/xmlschemas/GpxExtensions/v3",
|
||||||
|
"xmlns:wptx1": "http://www.garmin.com/xmlschemas/WaypointExtension/v1",
|
||||||
|
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
|
||||||
|
"xsi:schemaLocation": "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/WaypointExtension/v1 http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd",
|
||||||
|
},
|
||||||
|
"metadata": Object {
|
||||||
|
"time": "1970-01-01T00:00:00.000Z",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"type": "gpx",
|
||||||
|
},
|
||||||
|
"id": "gpx/4320000000000000",
|
||||||
|
"key": "gpx/4320000000000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"doc": Object {
|
||||||
|
"_id": "gpx/4320000000000000/3trk/000000",
|
||||||
|
"_rev": "1-4c114f3ae0073151e4082ff1d220c2a4",
|
||||||
|
"doc": Object {
|
||||||
|
"number": 0,
|
||||||
|
},
|
||||||
|
"type": "trk",
|
||||||
|
},
|
||||||
|
"id": "gpx/4320000000000000/3trk/000000",
|
||||||
|
"key": "gpx/4320000000000000/3trk/000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-4c114f3ae0073151e4082ff1d220c2a4",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"total_rows": 4,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
test('returns three rows after a gpx and a track segment have been inserted.', async () => {
|
||||||
|
await putNewTrkseg();
|
||||||
|
const allDocs: any = await getFamily('gpx/');
|
||||||
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"offset": 0,
|
||||||
|
"rows": Array [
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000",
|
||||||
|
"key": "gpx/4320000000000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000/3trk/000000",
|
||||||
|
"key": "gpx/4320000000000000/3trk/000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-4c114f3ae0073151e4082ff1d220c2a4",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000/3trk/000000/000000",
|
||||||
|
"key": "gpx/4320000000000000/3trk/000000/000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-68d7de0569de570229ea9f9e1a0b13cb",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"total_rows": 5,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
test('returns four rows after a gpx and a track point have been inserted.', async () => {
|
||||||
|
await putNewTrkpt();
|
||||||
|
const allDocs: any = await getFamily('gpx/');
|
||||||
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"offset": 0,
|
||||||
|
"rows": Array [
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000",
|
||||||
|
"key": "gpx/4320000000000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000/3trk/000000",
|
||||||
|
"key": "gpx/4320000000000000/3trk/000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-4c114f3ae0073151e4082ff1d220c2a4",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000/3trk/000000/000000",
|
||||||
|
"key": "gpx/4320000000000000/3trk/000000/000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-68d7de0569de570229ea9f9e1a0b13cb",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000/3trk/000000/000000/000000",
|
||||||
|
"key": "gpx/4320000000000000/3trk/000000/000000/000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-7d917d1f3505fe0e3092161694904b53",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"total_rows": 6,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns two rows after a gpx and a waypoint have been inserted.', async () => {
|
||||||
|
await putNewWpt();
|
||||||
|
const allDocs: any = await getFamily('gpx/');
|
||||||
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"offset": 0,
|
||||||
|
"rows": Array [
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000",
|
||||||
|
"key": "gpx/4320000000000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000/1wpt/000000",
|
||||||
|
"key": "gpx/4320000000000000/1wpt/000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-c6793365fd0dd56236ab8734a41c7ae7",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"total_rows": 4,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns two rows after a gpx and a route have been inserted.', async () => {
|
||||||
|
await putNewRte();
|
||||||
|
const allDocs: any = await getFamily('gpx/');
|
||||||
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"offset": 0,
|
||||||
|
"rows": Array [
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000",
|
||||||
|
"key": "gpx/4320000000000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000/2rte/000000",
|
||||||
|
"key": "gpx/4320000000000000/2rte/000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-2ca14f512a9c83f5a239389e580befce",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"total_rows": 4,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns three rows after a gpx and a route point have been inserted.', async () => {
|
||||||
|
await putNewRtept();
|
||||||
|
const allDocs: any = await getFamily('gpx/');
|
||||||
|
expect(allDocs).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"offset": 0,
|
||||||
|
"rows": Array [
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000",
|
||||||
|
"key": "gpx/4320000000000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-49baa096ec0c89962f2cafd3ff50b80b",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000/2rte/000000",
|
||||||
|
"key": "gpx/4320000000000000/2rte/000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-2ca14f512a9c83f5a239389e580befce",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": "gpx/4320000000000000/2rte/000000/000000",
|
||||||
|
"key": "gpx/4320000000000000/2rte/000000/000000",
|
||||||
|
"value": Object {
|
||||||
|
"rev": "1-0f4064d20f6bfac3888a7758851fbac5",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"total_rows": 5,
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getDocsByType', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await initDb({});
|
||||||
|
globalThis.Date.now = () => 0;
|
||||||
|
});
|
||||||
|
afterEach(async () => {
|
||||||
|
await db.destroy();
|
||||||
|
db = undefined;
|
||||||
|
globalThis.Date.now = originalDateNow;
|
||||||
|
});
|
||||||
|
test('gets the rte amongst other docs', async () => {
|
||||||
|
await putNewRtept();
|
||||||
|
const rtes = await getDocsByType('rte');
|
||||||
|
expect(rtes).toMatchInlineSnapshot(`
|
||||||
|
Array [
|
||||||
|
Object {
|
||||||
|
"_id": "gpx/4320000000000000/2rte/000000",
|
||||||
|
"_rev": "1-2ca14f512a9c83f5a239389e580befce",
|
||||||
|
"doc": Object {
|
||||||
|
"number": 0,
|
||||||
|
},
|
||||||
|
"type": "rte",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,7 +1,4 @@
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
import { state } from '../db-admin/health-legacy';
|
|
||||||
import { getParentId } from '../lib/docuri';
|
|
||||||
import { dbUrlToUserId } from '../lib/user-id';
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
var localDb: any;
|
var localDb: any;
|
||||||
|
@ -21,24 +18,13 @@ export const put = async (
|
||||||
try {
|
try {
|
||||||
current = await targetDb.get(_id);
|
current = await targetDb.get(_id);
|
||||||
} catch {
|
} catch {
|
||||||
const parentId = getParentId(_id);
|
current = { _rev: undefined, doc: cloneDeep(defaultDoc) };
|
||||||
let to;
|
|
||||||
try {
|
|
||||||
const parent = await db.get(parentId);
|
|
||||||
// console.log({ caller: 'put', parent });
|
|
||||||
to = parent.to;
|
|
||||||
} catch {}
|
|
||||||
current = { _rev: undefined, to, doc: cloneDeep(defaultDoc) };
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
putDoc = {
|
putDoc = {
|
||||||
_id,
|
_id,
|
||||||
_rev: current._rev,
|
_rev: current._rev,
|
||||||
type,
|
type,
|
||||||
to: current.to,
|
|
||||||
origin:
|
|
||||||
current.origin ??
|
|
||||||
(state().remoteUrl ? dbUrlToUserId(state().remoteUrl) : undefined),
|
|
||||||
doc: update(current.doc),
|
doc: update(current.doc),
|
||||||
};
|
};
|
||||||
await targetDb.put(putDoc);
|
await targetDb.put(putDoc);
|
||||||
|
@ -64,6 +50,16 @@ export const getFamily = async (
|
||||||
endkey,
|
endkey,
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
|
if (allDocs.rows.at(-1).id > endkey) {
|
||||||
|
console.error({
|
||||||
|
caller: 'getFamilly',
|
||||||
|
key,
|
||||||
|
endkey,
|
||||||
|
options,
|
||||||
|
local,
|
||||||
|
allDocs,
|
||||||
|
});
|
||||||
|
}
|
||||||
return allDocs;
|
return allDocs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,4 @@
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { putNewRte } from './rte';
|
||||||
import shell from 'shelljs';
|
|
||||||
|
|
||||||
import PouchDB from 'pouchdb';
|
|
||||||
|
|
||||||
import { getRte, putNewRte, putRte } from './rte';
|
|
||||||
import { put } from './lib';
|
|
||||||
import { emptyWpt } from './wpt';
|
|
||||||
import { sleep } from '../lib/async-wait';
|
|
||||||
import { debounce, memoize, property, wrap } from 'lodash';
|
|
||||||
import memoizee from 'memoizee';
|
|
||||||
|
|
||||||
const test = it;
|
|
||||||
const jest = vi;
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
var db: any;
|
var db: any;
|
||||||
|
@ -58,112 +45,3 @@ describe('The rte module', () => {
|
||||||
expect(id).toEqual({ gpx: 4320000000000000, rte: 0 });
|
expect(id).toEqual({ gpx: 4320000000000000, rte: 0 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('The rte module with a real db', () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
globalThis.db = new PouchDB('dyomedea', {
|
|
||||||
auto_compaction: false,
|
|
||||||
});
|
|
||||||
globalThis.Date.now = () => 0;
|
|
||||||
});
|
|
||||||
afterEach(async () => {
|
|
||||||
try {
|
|
||||||
await db.destroy();
|
|
||||||
} catch (err) {
|
|
||||||
// console.error(err);
|
|
||||||
await shell.exec('rm -rf $*$');
|
|
||||||
}
|
|
||||||
globalThis.db = undefined;
|
|
||||||
globalThis.dbReady = false;
|
|
||||||
globalThis.Date.now = originalDateNow;
|
|
||||||
});
|
|
||||||
it('can write and read a rte', async () => {
|
|
||||||
const id = 'whatever';
|
|
||||||
const rte: Rte = {
|
|
||||||
name: 'A new route',
|
|
||||||
};
|
|
||||||
const rtePut = await putRte({ id, rte });
|
|
||||||
expect(rtePut).toEqual(rte);
|
|
||||||
const rteGet = await getRte({ id });
|
|
||||||
expect(rteGet).toEqual(rte);
|
|
||||||
});
|
|
||||||
it('can write and read a rte with rtepts', async () => {
|
|
||||||
const id = 'whatever';
|
|
||||||
const rte: Rte = {
|
|
||||||
name: 'A new route',
|
|
||||||
rtept: [
|
|
||||||
{
|
|
||||||
$: { lat: 0, lon: 0 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const rtePut = await putRte({ id, rte });
|
|
||||||
expect(rtePut).toEqual(rte);
|
|
||||||
const rteGet = await getRte({ id });
|
|
||||||
expect(rteGet).toEqual(rte);
|
|
||||||
});
|
|
||||||
it('can read external rtepts ', async () => {
|
|
||||||
const idRte = 'gpx/4320836410265485/2rte/000034';
|
|
||||||
const idRtept = 'gpx/4320836410265485/2rte/000034/000035';
|
|
||||||
const rtept3: Wpt = {
|
|
||||||
$: { lat: 3, lon: 3 },
|
|
||||||
};
|
|
||||||
const rte0: Rte = {
|
|
||||||
name: 'A new route',
|
|
||||||
rtept: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const rte1: Rte = {
|
|
||||||
name: 'A new route',
|
|
||||||
rtept: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
rtept3,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const rtePut = await putRte({ id: idRte, rte: rte0 });
|
|
||||||
expect(rtePut).toEqual(rte0);
|
|
||||||
await put(idRtept, 'rtept', () => rtept3, emptyWpt);
|
|
||||||
expect(await getRte({ id: idRte })).toEqual(rte1);
|
|
||||||
});
|
|
||||||
|
|
||||||
// it('debounces correctly by param ', async () => {
|
|
||||||
// let values = [0, 1, 2, 3, 4, 5];
|
|
||||||
// const decrement = (params: any) => {
|
|
||||||
// const { id } = params;
|
|
||||||
// //await sleep(1);
|
|
||||||
// values[2] = values[2] - 1;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const debounceByParam = (targetFunc, resolver, ...debounceParams) =>
|
|
||||||
// wrap(
|
|
||||||
// memoize(() => debounce(targetFunc, ...debounceParams), resolver),
|
|
||||||
// (getMemoizedFunc, ...params) => getMemoizedFunc(...params)(...params)
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const debouncedDecrement = debounce(decrement, 100);
|
|
||||||
// debouncedDecrement({ id: 2 });
|
|
||||||
// debouncedDecrement({ id: 2 });
|
|
||||||
// debouncedDecrement({ id: 5 });
|
|
||||||
// debouncedDecrement({ id: 2 });
|
|
||||||
// debouncedDecrement({ id: 5 });
|
|
||||||
// debouncedDecrement({ id: 2 });
|
|
||||||
// debouncedDecrement({ id: 2 });
|
|
||||||
// debouncedDecrement({ id: 2 });
|
|
||||||
// await sleep(2000);
|
|
||||||
// expect(values).toEqual([0, 1, 1, 3, 4, 4]);
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
|
|
109
src/db/rte.ts
|
@ -1,6 +1,5 @@
|
||||||
import { cloneDeep, debounce, memoize, property, wrap } from 'lodash';
|
|
||||||
import getUri from '../lib/ids';
|
import getUri from '../lib/ids';
|
||||||
import { putNewGpx } from './gpx';
|
import { appendToArray, putNewGpx } from './gpx';
|
||||||
import { getFamily, put } from './lib';
|
import { getFamily, put } from './lib';
|
||||||
|
|
||||||
export const emptyRte: Rte = {
|
export const emptyRte: Rte = {
|
||||||
|
@ -33,90 +32,42 @@ export const putNewRte = async (id?: IdRte | IdGpx) => {
|
||||||
return finalId as IdRte;
|
return finalId as IdRte;
|
||||||
};
|
};
|
||||||
|
|
||||||
// See https://stackoverflow.com/questions/28787436/debounce-a-function-with-argument
|
|
||||||
|
|
||||||
export const debounceByParam = (
|
|
||||||
targetFunc: (params: any) => any,
|
|
||||||
resolver: (params: any) => any,
|
|
||||||
...debounceParams: any
|
|
||||||
) =>
|
|
||||||
wrap(
|
|
||||||
memoize(() => debounce(targetFunc, ...debounceParams), resolver),
|
|
||||||
(getMemoizedFunc, ...params) => getMemoizedFunc(...params)(...params)
|
|
||||||
);
|
|
||||||
|
|
||||||
export const compactRteOrTrkseg = async (params: any) => {
|
|
||||||
const { getDocs } = params;
|
|
||||||
const { docs, rte, trkseg } = await getDocs(params);
|
|
||||||
if (docs.rows.length > 1) {
|
|
||||||
const compactedDocs = docs.rows.map((row: any) => {
|
|
||||||
if (['rte', 'trkseg'].includes(row.doc.type)) {
|
|
||||||
return { ...row.doc, doc: rte || trkseg };
|
|
||||||
}
|
|
||||||
return { ...row.doc, doc: undefined, _deleted: true };
|
|
||||||
});
|
|
||||||
console.log({
|
|
||||||
caller: 'compactRteOrTrkseg',
|
|
||||||
params,
|
|
||||||
compactedDocs,
|
|
||||||
firstDoc: compactedDocs[0].doc,
|
|
||||||
firstDocWpt: compactedDocs[0].doc.trkpt[0],
|
|
||||||
date: new Date().toISOString(),
|
|
||||||
});
|
|
||||||
await db.bulkDocs(compactedDocs);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const compactRteOrTrksegDebounced = debounceByParam(
|
|
||||||
compactRteOrTrkseg,
|
|
||||||
property('id'),
|
|
||||||
60 * 60 * 1000 * (1 + Math.random())
|
|
||||||
);
|
|
||||||
|
|
||||||
export const getRteDocs: ({
|
|
||||||
id,
|
|
||||||
}: {
|
|
||||||
id: string;
|
|
||||||
}) => Promise<{ docs: any; rte: Rte }> = async (params) => {
|
|
||||||
const { id } = params;
|
|
||||||
const docs = await getFamily(id, { include_docs: true });
|
|
||||||
let rte: Rte;
|
|
||||||
if (docs.rows.length === 1) {
|
|
||||||
rte = docs.rows[0].doc.doc;
|
|
||||||
} else {
|
|
||||||
rte = cloneDeep(docs.rows[0].doc.doc);
|
|
||||||
if (!rte.rtept) {
|
|
||||||
rte.rtept = [];
|
|
||||||
}
|
|
||||||
docs.rows.slice(1).forEach((row: any) => {
|
|
||||||
rte.rtept.push(row.doc.doc);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// console.log({
|
|
||||||
// caller: 'getRteDocs',
|
|
||||||
// id,
|
|
||||||
// docs,
|
|
||||||
// nbRteptIn: docs.rows[0].doc.doc.rtept?.length,
|
|
||||||
// nbRteptTotal: rte?.rtept?.length,
|
|
||||||
// });
|
|
||||||
return { docs, rte };
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getRte = async (params: any) => {
|
export const getRte = async (params: any) => {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { docs, rte } = await getRteDocs(params);
|
const docs = await getFamily(id, { include_docs: true });
|
||||||
if (docs.rows.length > 1) {
|
let target: any[];
|
||||||
console.log({
|
let rte: Rte | undefined = undefined;
|
||||||
caller: 'getRte compactRteOrTrksegDebounced required',
|
docs.rows.every((row: any) => {
|
||||||
id,
|
// level 0
|
||||||
});
|
if (row.doc.type === 'rte') {
|
||||||
compactRteOrTrksegDebounced({ id, getDocs: getRteDocs });
|
if (!!rte) {
|
||||||
}
|
console.error({
|
||||||
|
caller: 'getRte',
|
||||||
|
id,
|
||||||
|
row,
|
||||||
|
target,
|
||||||
|
rte,
|
||||||
|
});
|
||||||
|
return false; // Hack to stop if getFamily fails
|
||||||
|
}
|
||||||
|
target = [row.doc.doc];
|
||||||
|
rte = row.doc.doc;
|
||||||
|
}
|
||||||
|
//level 1
|
||||||
|
if (row.doc.type === 'rtept') {
|
||||||
|
target.splice(1);
|
||||||
|
row.doc.doc.id = row.doc._id;
|
||||||
|
appendToArray(target.at(-1), row.doc.type, row.doc.doc);
|
||||||
|
target.push(row.doc.doc);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
return rte;
|
return rte;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const putRte = async (params: any) => {
|
export const putRte = async (params: any) => {
|
||||||
const { id, rte } = params;
|
const { id, rte } = params;
|
||||||
|
rte.rtept = undefined;
|
||||||
await put(id, 'rte', (doc) => rte, rte);
|
await put(id, 'rte', (doc) => rte, rte);
|
||||||
return rte;
|
return rte;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,14 +1,4 @@
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { putNewRtept } from './rtept';
|
||||||
import shell from 'shelljs';
|
|
||||||
import PouchDB from 'pouchdb';
|
|
||||||
import { getRte, compactRteOrTrksegDebounced, putRte } from './rte';
|
|
||||||
|
|
||||||
import { putRtept } from './rtept';
|
|
||||||
import { get, getFamily, put } from './lib';
|
|
||||||
import { emptyWpt } from './wpt';
|
|
||||||
|
|
||||||
const test = it;
|
|
||||||
const jest = vi;
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
var db: any;
|
var db: any;
|
||||||
|
@ -18,172 +8,51 @@ declare global {
|
||||||
const originalDb = globalThis.db;
|
const originalDb = globalThis.db;
|
||||||
const originalDateNow = globalThis.Date.now;
|
const originalDateNow = globalThis.Date.now;
|
||||||
|
|
||||||
describe('The rtept module with a real db', () => {
|
describe('The rtept module', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(() => {
|
||||||
globalThis.db = new PouchDB('dyomedea', {
|
globalThis.db = { put: jest.fn() };
|
||||||
auto_compaction: false,
|
|
||||||
});
|
|
||||||
globalThis.Date.now = () => 0;
|
globalThis.Date.now = () => 0;
|
||||||
vi.mock('compactRteOrTrksegDebounced', () => {
|
|
||||||
console.log({ caller: 'mocked compactRteOrTrksegDebounced' });
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
afterEach(async () => {
|
afterEach(() => {
|
||||||
try {
|
globalThis.db = originalDb;
|
||||||
await db.destroy();
|
|
||||||
} catch (err) {
|
|
||||||
// console.error(err);
|
|
||||||
await shell.exec('rm -rf $*$');
|
|
||||||
}
|
|
||||||
globalThis.db = undefined;
|
|
||||||
globalThis.dbReady = false;
|
|
||||||
globalThis.Date.now = originalDateNow;
|
globalThis.Date.now = originalDateNow;
|
||||||
});
|
});
|
||||||
it('can write a rtept inside a rte', async () => {
|
test('db.put() a new rtept when required', async () => {
|
||||||
const idRte = 'whatever';
|
putNewRtept({ gpx: 0, rte: 0, rtept: 0 });
|
||||||
const rtept: Wpt = {
|
await expect(globalThis.db.put).toBeCalledWith({
|
||||||
$: { lat: 2, lon: 2 },
|
_id: 'gpx/0000000000000000/2rte/000000/000000',
|
||||||
};
|
_rev: undefined,
|
||||||
const rte0: Rte = {
|
doc: {
|
||||||
name: 'A new route',
|
$: { lat: 0, lon: 0 },
|
||||||
rtept: [
|
ageofdgpsdata: undefined,
|
||||||
{
|
cmt: undefined,
|
||||||
$: { lat: 0, lon: 0 },
|
desc: undefined,
|
||||||
},
|
dgpsid: undefined,
|
||||||
{
|
ele: undefined,
|
||||||
$: { lat: 1, lon: 1 },
|
extensions: undefined,
|
||||||
},
|
fix: undefined,
|
||||||
],
|
geoidheight: undefined,
|
||||||
};
|
hdop: undefined,
|
||||||
const rte1: Rte = {
|
link: undefined,
|
||||||
name: 'A new route',
|
magvar: undefined,
|
||||||
rtept: [
|
name: undefined,
|
||||||
{
|
pdop: undefined,
|
||||||
$: { lat: 0, lon: 0 },
|
sat: undefined,
|
||||||
},
|
src: undefined,
|
||||||
{
|
sym: undefined,
|
||||||
$: { lat: 2, lon: 2 },
|
time: undefined,
|
||||||
},
|
type: undefined,
|
||||||
],
|
vdop: undefined,
|
||||||
};
|
},
|
||||||
|
type: 'rtept',
|
||||||
const rtePut = await putRte({ id: idRte, rte: rte0 });
|
|
||||||
expect(rtePut).toEqual(rte0);
|
|
||||||
const rtePutRtept = await putRtept({ id: idRte, index: 1, wpt: rtept });
|
|
||||||
const rteGetRtept = await getRte({ id: idRte });
|
|
||||||
expect(rteGetRtept).toEqual(rte1);
|
|
||||||
});
|
|
||||||
it('can write a rtept outside a rte', async () => {
|
|
||||||
const idRte = 'gpx/4320836410265485/2rte/000034';
|
|
||||||
const idRtept = 'gpx/4320836410265485/2rte/000034/000035';
|
|
||||||
const rtept3: Wpt = {
|
|
||||||
$: { lat: 3, lon: 3 },
|
|
||||||
};
|
|
||||||
const rtept4: Wpt = {
|
|
||||||
$: { lat: 4, lon: 4 },
|
|
||||||
};
|
|
||||||
const rte0: Rte = {
|
|
||||||
name: 'A new route',
|
|
||||||
rtept: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const rte1: Rte = {
|
|
||||||
name: 'A new route',
|
|
||||||
rtept: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
rtept3,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const rte2: Rte = {
|
|
||||||
name: 'A new route',
|
|
||||||
rtept: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
rtept4,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const rtePut = await putRte({ id: idRte, rte: rte0 });
|
|
||||||
expect(rtePut).toEqual(rte0);
|
|
||||||
await put(idRtept, 'rtept', () => rtept3, emptyWpt);
|
|
||||||
expect(await getRte({ id: idRte })).toEqual(rte1);
|
|
||||||
await putRtept({
|
|
||||||
id: idRte,
|
|
||||||
index: 2,
|
|
||||||
wpt: rtept4,
|
|
||||||
});
|
});
|
||||||
expect((await getFamily(idRte)).rows.length).toEqual(2);
|
|
||||||
expect(await getRte({ id: idRte })).toEqual(rte2);
|
|
||||||
expect((await get(idRtept)).doc).toEqual(rtept4);
|
|
||||||
});
|
});
|
||||||
it('can write a rtept outside a rte with a negative index', async () => {
|
test('db.put() generates an id for the rtept if needed', async () => {
|
||||||
const idRte = 'gpx/4320836410265485/2rte/000034';
|
const id = await putNewRtept({ gpx: 0 });
|
||||||
const idRtept = 'gpx/4320836410265485/2rte/000034/000035';
|
expect(id).toEqual({ gpx: 0, rte: 0, rtept: 0 });
|
||||||
const rtept3: Wpt = {
|
});
|
||||||
$: { lat: 3, lon: 3 },
|
test('db.put() generates ids for both gpx and rte if needed', async () => {
|
||||||
};
|
const id = await putNewRtept();
|
||||||
const rtept4: Wpt = {
|
expect(id).toEqual({ gpx: 4320000000000000, rte: 0, rtept: 0 });
|
||||||
$: { lat: 4, lon: 4 },
|
|
||||||
};
|
|
||||||
const rte0: Rte = {
|
|
||||||
name: 'A new route',
|
|
||||||
rtept: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const rte1: Rte = {
|
|
||||||
name: 'A new route',
|
|
||||||
rtept: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
rtept3,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const rte2: Rte = {
|
|
||||||
name: 'A new route',
|
|
||||||
rtept: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
rtept4,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const rtePut = await putRte({ id: idRte, rte: rte0 });
|
|
||||||
await put(idRtept, 'rtept', () => rtept3, emptyWpt);
|
|
||||||
await putRtept({
|
|
||||||
id: idRte,
|
|
||||||
index: -1,
|
|
||||||
wpt: rtept4,
|
|
||||||
});
|
|
||||||
expect(await getRte({ id: idRte })).toEqual(rte2);
|
|
||||||
expect((await get(idRtept)).doc).toEqual(rtept4);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { getRteDocs, putRte } from './rte';
|
|
||||||
import getUri from '../lib/ids';
|
import getUri from '../lib/ids';
|
||||||
import { put } from './lib';
|
import { put } from './lib';
|
||||||
|
import { putNewRte } from './rte';
|
||||||
|
|
||||||
export const emptyRtept: Wpt = {
|
export const emptyRtept: Wpt = {
|
||||||
$: { lat: 0, lon: 0 },
|
$: { lat: 0, lon: 0 },
|
||||||
|
@ -25,27 +25,27 @@ export const emptyRtept: Wpt = {
|
||||||
extensions: undefined,
|
extensions: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const putRtept = async (params: any) => {
|
export const putNewRtept = async (id?: IdGpx | IdRte | IdRtept) => {
|
||||||
const { id, index, wpt } = params;
|
let finalId = { ...id };
|
||||||
const { docs } = await getRteDocs({ id: id });
|
if (!('rtept' in finalId)) {
|
||||||
const rte = docs.rows[0].doc.doc;
|
const rteId = await putNewRte(id);
|
||||||
const nbRteptInRte = rte && rte.rtept ? rte.rtept.length : 0;
|
finalId = { ...rteId, rtept: 0 };
|
||||||
const nbRteptOutRte = docs.rows.length - 1;
|
|
||||||
const nbRtept = nbRteptInRte + nbRteptOutRte;
|
|
||||||
const positiveIndex = index >= 0 ? index : nbRtept + index;
|
|
||||||
// console.log({
|
|
||||||
// caller: 'putRtept',
|
|
||||||
// nbRteptInRte,
|
|
||||||
// nbRteptOutRte,
|
|
||||||
// nbRtept,
|
|
||||||
// positiveIndex,
|
|
||||||
// });
|
|
||||||
if (positiveIndex < nbRteptInRte) {
|
|
||||||
rte.rtept[positiveIndex] = wpt;
|
|
||||||
await putRte({ id, rte });
|
|
||||||
} else {
|
|
||||||
const reptId = docs.rows[1 + positiveIndex - nbRteptInRte].doc._id;
|
|
||||||
await put(reptId, 'rtept', () => wpt, emptyRtept);
|
|
||||||
}
|
}
|
||||||
return wpt;
|
const uri = getUri('rtept', finalId);
|
||||||
|
await put(
|
||||||
|
uri,
|
||||||
|
'rtept',
|
||||||
|
(rtept) => {
|
||||||
|
return rtept;
|
||||||
|
},
|
||||||
|
emptyRtept
|
||||||
|
);
|
||||||
|
return finalId as IdRtept;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const putRtept = async (params: any) => {
|
||||||
|
const { id, rtept } = params;
|
||||||
|
rtept.id = undefined;
|
||||||
|
await put(id, 'rtept', (doc) => rtept, rtept);
|
||||||
|
return rtept;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
import { putNewTrk } from './trk';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
var db: any;
|
||||||
|
var dbReady: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const originalDb = globalThis.db;
|
||||||
|
const originalDateNow = globalThis.Date.now;
|
||||||
|
|
||||||
|
describe('The trk module', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
globalThis.db = { put: jest.fn() };
|
||||||
|
globalThis.Date.now = () => 0;
|
||||||
|
});
|
||||||
|
afterEach(() => {
|
||||||
|
globalThis.db = originalDb;
|
||||||
|
globalThis.Date.now = originalDateNow;
|
||||||
|
});
|
||||||
|
test('db.put() a new trk when required', async () => {
|
||||||
|
putNewTrk({ gpx: 1, trk: 2 });
|
||||||
|
await expect(globalThis.db.put).toBeCalledWith({
|
||||||
|
_id: 'gpx/0000000000000001/3trk/000002',
|
||||||
|
_rev: undefined,
|
||||||
|
doc: {
|
||||||
|
cmt: undefined,
|
||||||
|
desc: undefined,
|
||||||
|
extensions: undefined,
|
||||||
|
link: undefined,
|
||||||
|
name: undefined,
|
||||||
|
number: 0,
|
||||||
|
src: undefined,
|
||||||
|
trkseg: undefined,
|
||||||
|
type: undefined,
|
||||||
|
},
|
||||||
|
type: 'trk',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('db.put() generates an id for the trk if needed', async () => {
|
||||||
|
const id = await putNewTrk({ gpx: 2 });
|
||||||
|
expect(id).toEqual({ gpx: 2, trk: 0});
|
||||||
|
});
|
||||||
|
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||||
|
const id = await putNewTrk();
|
||||||
|
expect(id).toEqual({ gpx: 4320000000000000, trk: 0});
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,14 +1,4 @@
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { putNewTrkpt } from './trkpt';
|
||||||
import shell from 'shelljs';
|
|
||||||
import PouchDB from 'pouchdb';
|
|
||||||
import { getTrkseg, getTrksegDocs, putTrkseg } from './trkseg';
|
|
||||||
|
|
||||||
import { putTrkpt } from './trkpt';
|
|
||||||
import { get, getFamily, put } from './lib';
|
|
||||||
import { emptyWpt } from './wpt';
|
|
||||||
|
|
||||||
const test = it;
|
|
||||||
const jest = vi;
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
var db: any;
|
var db: any;
|
||||||
|
@ -18,180 +8,72 @@ declare global {
|
||||||
const originalDb = globalThis.db;
|
const originalDb = globalThis.db;
|
||||||
const originalDateNow = globalThis.Date.now;
|
const originalDateNow = globalThis.Date.now;
|
||||||
|
|
||||||
describe('The trkpt module with a real db', () => {
|
describe('The trkpt module', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(() => {
|
||||||
globalThis.db = new PouchDB('dyomedea', {
|
globalThis.db = { put: jest.fn() };
|
||||||
auto_compaction: false,
|
|
||||||
});
|
|
||||||
globalThis.Date.now = () => 0;
|
globalThis.Date.now = () => 0;
|
||||||
// vi.mock('./rte', async () => {
|
|
||||||
// const originalModule = await vi.importActual('./rte');
|
|
||||||
// return {
|
|
||||||
// ...originalModule,
|
|
||||||
// compactTrksegOrTrksegDebounced: () => {
|
|
||||||
// console.log('mocked compactTrksegOrTrksegDebounced');
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
afterEach(async () => {
|
afterEach(() => {
|
||||||
try {
|
globalThis.db = originalDb;
|
||||||
await db.destroy();
|
|
||||||
} catch (err) {
|
|
||||||
// console.error(err);
|
|
||||||
await shell.exec('rm -rf $*$');
|
|
||||||
}
|
|
||||||
globalThis.db = undefined;
|
|
||||||
globalThis.dbReady = false;
|
|
||||||
globalThis.Date.now = originalDateNow;
|
globalThis.Date.now = originalDateNow;
|
||||||
});
|
});
|
||||||
it('can write a trkpt inside a trkseg', async () => {
|
test('db.put() a new trkpt when required', async () => {
|
||||||
const idTrkseg = 'gpx/4320836410265485/2trkseg/000034';
|
putNewTrkpt({
|
||||||
const trkpt: Wpt = {
|
gpx: 1,
|
||||||
$: { lat: 2, lon: 2 },
|
trk: 2,
|
||||||
};
|
trkseg: 3,
|
||||||
const trkseg0: Trkseg = {
|
trkpt: 4,
|
||||||
trkpt: [
|
});
|
||||||
{
|
await expect(globalThis.db.put).toBeCalledWith({
|
||||||
$: { lat: 0, lon: 0 },
|
_id: 'gpx/0000000000000001/3trk/000002/000003/000004',
|
||||||
},
|
_rev: undefined,
|
||||||
{
|
doc: {
|
||||||
$: { lat: 1, lon: 1 },
|
$: { lat: 0, lon: 0 },
|
||||||
},
|
ageofdgpsdata: undefined,
|
||||||
],
|
cmt: undefined,
|
||||||
};
|
desc: undefined,
|
||||||
const trkseg1: Trkseg = {
|
dgpsid: undefined,
|
||||||
trkpt: [
|
ele: undefined,
|
||||||
{
|
extensions: {
|
||||||
$: { lat: 0, lon: 0 },
|
'dyo:accuracy': undefined,
|
||||||
},
|
'dyo:batterylevel': undefined,
|
||||||
{
|
'dyo:course': undefined,
|
||||||
$: { lat: 2, lon: 2 },
|
'dyo:speed': undefined,
|
||||||
},
|
'dyo:useragent': undefined,
|
||||||
],
|
},
|
||||||
};
|
fix: undefined,
|
||||||
|
geoidheight: undefined,
|
||||||
const trksegPut = await putTrkseg(idTrkseg, trkseg0);
|
hdop: undefined,
|
||||||
expect(trksegPut).toEqual(idTrkseg);
|
link: undefined,
|
||||||
const trksegPutTrksegpt = await putTrkpt({
|
magvar: undefined,
|
||||||
id: idTrkseg,
|
name: undefined,
|
||||||
index: 1,
|
pdop: undefined,
|
||||||
wpt: trkpt,
|
sat: undefined,
|
||||||
|
src: undefined,
|
||||||
|
sym: undefined,
|
||||||
|
time: undefined,
|
||||||
|
type: undefined,
|
||||||
|
vdop: undefined,
|
||||||
|
},
|
||||||
|
type: 'trkpt',
|
||||||
});
|
});
|
||||||
const trksegGetTrksegpt = await getTrkseg({ id: idTrkseg });
|
|
||||||
expect(trksegGetTrksegpt).toEqual(trkseg1);
|
|
||||||
});
|
});
|
||||||
it('can write a trkpt outside a trkseg', async () => {
|
test('db.put() generates an id for the trk if needed', async () => {
|
||||||
const idTrkseg = 'gpx/4320836410265485/2trkseg/000034';
|
const id = await putNewTrkpt({ gpx: 5 });
|
||||||
const idTrksegpt = 'gpx/4320836410265485/2trkseg/000034/000035';
|
expect(id).toEqual({
|
||||||
const trkpt3: Wpt = {
|
gpx: 5,
|
||||||
$: { lat: 3, lon: 3 },
|
trk: 0,
|
||||||
};
|
trkseg: 0,
|
||||||
const trkpt4: Wpt = {
|
trkpt: 0,
|
||||||
$: { lat: 4, lon: 4 },
|
|
||||||
};
|
|
||||||
const trkseg0: Trkseg = {
|
|
||||||
trkpt: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const trkseg1: Trkseg = {
|
|
||||||
trkpt: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
trkpt3,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const trkseg2: Trkseg = {
|
|
||||||
trkpt: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
trkpt4,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const trksegPut = await putTrkseg(idTrkseg, trkseg0);
|
|
||||||
expect(trksegPut).toEqual(idTrkseg);
|
|
||||||
expect(await getTrkseg({ id: idTrkseg })).toEqual(trkseg0);
|
|
||||||
await put(idTrksegpt, 'trkpt', () => trkpt3, emptyWpt);
|
|
||||||
const { trkseg, docs } = await getTrksegDocs({ id: idTrkseg });
|
|
||||||
console.log({
|
|
||||||
caller: 'test',
|
|
||||||
trkptIn: JSON.stringify(docs.rows[0].doc.doc.trkpt),
|
|
||||||
});
|
});
|
||||||
expect(await getTrkseg({ id: idTrkseg })).toEqual(trkseg1);
|
|
||||||
await putTrkpt({
|
|
||||||
id: idTrkseg,
|
|
||||||
index: 2,
|
|
||||||
wpt: trkpt4,
|
|
||||||
});
|
|
||||||
expect((await getFamily(idTrkseg)).rows.length).toEqual(2);
|
|
||||||
expect(await getTrkseg({ id: idTrkseg })).toEqual(trkseg2);
|
|
||||||
expect((await get(idTrksegpt)).doc).toEqual(trkpt4);
|
|
||||||
});
|
});
|
||||||
it('can write a trkpt outside a trkseg with a negative index', async () => {
|
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||||
const idTrkseg = 'gpx/4320836410265485/2trkseg/000034';
|
const id = await putNewTrkpt();
|
||||||
const idTrksegpt = 'gpx/4320836410265485/2trkseg/000034/000035';
|
expect(id).toEqual({
|
||||||
const trkpt3: Wpt = {
|
gpx: 4320000000000000,
|
||||||
$: { lat: 3, lon: 3 },
|
trk: 0,
|
||||||
};
|
trkseg: 0,
|
||||||
const trkpt4: Wpt = {
|
trkpt: 0,
|
||||||
$: { lat: 4, lon: 4 },
|
|
||||||
};
|
|
||||||
const trkseg0: Trkseg = {
|
|
||||||
trkpt: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const trkseg1: Trkseg = {
|
|
||||||
trkpt: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
trkpt3,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const trkseg2: Trkseg = {
|
|
||||||
trkpt: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
trkpt4,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const trksegPut = await putTrkseg(idTrkseg, trkseg0);
|
|
||||||
await put(idTrksegpt, 'trkpt', () => trkpt3, emptyWpt);
|
|
||||||
await putTrkpt({
|
|
||||||
id: idTrkseg,
|
|
||||||
index: -1,
|
|
||||||
wpt: trkpt4,
|
|
||||||
});
|
|
||||||
expect(await getTrkseg({ id: idTrkseg })).toEqual(trkseg2);
|
|
||||||
expect((await get(idTrksegpt)).doc).toEqual(trkpt4);
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import getUri, { intToTrkptId } from '../lib/ids';
|
import getUri, { intToTrkptId } from '../lib/ids';
|
||||||
import { put } from './lib';
|
import { put } from './lib';
|
||||||
import { getTrksegDocs, putTrkseg } from './trkseg';
|
import { putNewTrkseg } from './trkseg';
|
||||||
import { emptyWpt } from './wpt';
|
|
||||||
|
|
||||||
const emptyTrkpt: Wpt = {
|
const emptyTrkpt: Wpt = {
|
||||||
$: { lat: 0, lon: 0 },
|
$: { lat: 0, lon: 0 },
|
||||||
|
@ -32,28 +31,28 @@ const emptyTrkpt: Wpt = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const putTrkpt = async (params: any) => {
|
export const putNewTrkpt = async (id?: IdTrk | IdGpx | IdTrkseg | IdTrkpt) => {
|
||||||
const { id, index, wpt } = params;
|
let finalId = { ...id };
|
||||||
const { docs } = await getTrksegDocs({ id: id });
|
if (!('trkpt' in finalId)) {
|
||||||
const trkseg = docs.rows[0].doc.doc;
|
const trksegId = await putNewTrkseg(id);
|
||||||
const nbWptInTrkseg = trkseg && trkseg.trkpt ? trkseg.trkpt.length : 0;
|
finalId = { ...trksegId, trkpt: intToTrkptId(Date.now()) };
|
||||||
const nbWptOutTrkseg = docs.rows.length - 1;
|
|
||||||
const nbWpt = nbWptInTrkseg + nbWptOutTrkseg;
|
|
||||||
const positiveIndex = index >= 0 ? index : nbWpt + index;
|
|
||||||
console.log({
|
|
||||||
caller: 'putTrkpt',
|
|
||||||
nbWptInTrkseg,
|
|
||||||
nbWptOutTrkseg,
|
|
||||||
nbWpt,
|
|
||||||
positiveIndex,
|
|
||||||
trkpt: JSON.stringify(trkseg.trkpt),
|
|
||||||
});
|
|
||||||
if (positiveIndex < nbWptInTrkseg) {
|
|
||||||
trkseg.trkpt[positiveIndex] = wpt;
|
|
||||||
await putTrkseg(id, trkseg);
|
|
||||||
} else {
|
|
||||||
const trkptId = docs.rows[1 + positiveIndex - nbWptInTrkseg].doc._id;
|
|
||||||
await put(trkptId, 'trkpt', () => wpt, emptyWpt);
|
|
||||||
}
|
}
|
||||||
return wpt;
|
const uri = getUri('trkpt', finalId);
|
||||||
|
await put(
|
||||||
|
uri,
|
||||||
|
'trkpt',
|
||||||
|
(trkpt) => {
|
||||||
|
return trkpt;
|
||||||
|
},
|
||||||
|
emptyTrkpt
|
||||||
|
);
|
||||||
|
return finalId;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const putTrkpt = async (params: any) => {
|
||||||
|
const { id, trkpt } = params;
|
||||||
|
trkpt.id = undefined;
|
||||||
|
await put(id, 'trkpt', (doc) => trkpt, trkpt);
|
||||||
|
return trkpt;
|
||||||
};
|
};
|
|
@ -1,18 +1,4 @@
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { putNewTrkseg } from './trkseg';
|
||||||
import shell from 'shelljs';
|
|
||||||
|
|
||||||
import PouchDB from 'pouchdb';
|
|
||||||
|
|
||||||
import { appendTrkpt, getTrkseg, getTrksegDocs, putTrkseg } from './trkseg';
|
|
||||||
import getUri from '../lib/ids';
|
|
||||||
|
|
||||||
import { put } from './lib';
|
|
||||||
import { emptyWpt } from './wpt';
|
|
||||||
import { compactRteOrTrkseg } from './rte';
|
|
||||||
import { sleep } from '../lib/async-wait';
|
|
||||||
|
|
||||||
const test = it;
|
|
||||||
const jest = vi;
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
var db: any;
|
var db: any;
|
||||||
|
@ -22,171 +8,33 @@ declare global {
|
||||||
const originalDb = globalThis.db;
|
const originalDb = globalThis.db;
|
||||||
const originalDateNow = globalThis.Date.now;
|
const originalDateNow = globalThis.Date.now;
|
||||||
|
|
||||||
describe('The trkseg module with a real db', () => {
|
describe('The trkseg module', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(() => {
|
||||||
globalThis.db = new PouchDB('dyomedea', {
|
globalThis.db = { put: jest.fn() };
|
||||||
auto_compaction: false,
|
|
||||||
});
|
|
||||||
globalThis.Date.now = () => 0;
|
globalThis.Date.now = () => 0;
|
||||||
});
|
});
|
||||||
afterEach(async () => {
|
afterEach(() => {
|
||||||
try {
|
globalThis.db = originalDb;
|
||||||
await db.destroy();
|
|
||||||
} catch (err) {
|
|
||||||
// console.error(err);
|
|
||||||
await shell.exec('rm -rf $*$');
|
|
||||||
}
|
|
||||||
globalThis.db = undefined;
|
|
||||||
globalThis.dbReady = false;
|
|
||||||
globalThis.Date.now = originalDateNow;
|
globalThis.Date.now = originalDateNow;
|
||||||
});
|
});
|
||||||
it('can write and read a trkseg', async () => {
|
test('db.put() a new trk when required', async () => {
|
||||||
const id = 'gpx/4320836036089189/3trk/000000/000000';
|
putNewTrkseg({ gpx: 1234567890123456, trk: 123456, trkseg: 5 });
|
||||||
const trkseg: Trkseg = {};
|
await expect(globalThis.db.put).toBeCalledWith({
|
||||||
const trksegPut = await putTrkseg(id, trkseg);
|
_id: 'gpx/1234567890123456/3trk/123456/000005',
|
||||||
const trksegGet = await getTrkseg({ id });
|
_rev: undefined,
|
||||||
expect(trksegGet).toEqual(trkseg);
|
doc: {
|
||||||
});
|
trkpt: undefined,
|
||||||
it('can write and read a trkseg with trkpts', async () => {
|
extensions: undefined,
|
||||||
const id = 'whatever';
|
},
|
||||||
const trkseg: Trkseg = {
|
type: 'trkseg',
|
||||||
trkpt: [
|
|
||||||
{
|
|
||||||
$: { lat: 0, lon: 0 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const trksegPut = await putTrkseg(id, trkseg);
|
|
||||||
const trksegGet = await getTrkseg({ id });
|
|
||||||
expect(trksegGet).toEqual(trkseg);
|
|
||||||
});
|
|
||||||
it('can read external trkpts ', async () => {
|
|
||||||
const idTrkseg = 'gpx/4320836036089189/3trk/000000/000000';
|
|
||||||
const idTrksegpt = 'gpx/4320836036089189/3trk/000000/000000/000035';
|
|
||||||
const trkpt3: Wpt = {
|
|
||||||
$: { lat: 3, lon: 3 },
|
|
||||||
};
|
|
||||||
const trkseg0: Trkseg = {
|
|
||||||
trkpt: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const trkseg1: Trkseg = {
|
|
||||||
trkpt: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
trkpt3,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const trksegPut = await putTrkseg(idTrkseg, trkseg0);
|
|
||||||
await put(idTrksegpt, 'trkpt', () => trkpt3, emptyWpt);
|
|
||||||
expect(await getTrkseg({ id: idTrkseg })).toEqual(trkseg1);
|
|
||||||
});
|
|
||||||
it('can can append a new trkpt ', async () => {
|
|
||||||
const idTrkseg = 'gpx/4320836036089189/3trk/000000/000000';
|
|
||||||
const trkpt3: Wpt = {
|
|
||||||
$: { lat: 3, lon: 3 },
|
|
||||||
};
|
|
||||||
const trkseg0: Trkseg = {
|
|
||||||
trkpt: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const trkseg1: Trkseg = {
|
|
||||||
trkpt: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
trkpt3,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
await putTrkseg(idTrkseg, trkseg0);
|
|
||||||
await appendTrkpt({
|
|
||||||
trksegIdObj: getUri('trkseg', idTrkseg),
|
|
||||||
trkpt: trkpt3,
|
|
||||||
});
|
});
|
||||||
expect(await getTrkseg({ id: idTrkseg })).toEqual(trkseg1);
|
|
||||||
});
|
});
|
||||||
|
test('db.put() generates an id for the trk if needed', async () => {
|
||||||
it('can compact external trkpts after existing internal trkpts', async () => {
|
const id = await putNewTrkseg({ gpx: 1 });
|
||||||
const idTrkseg = 'gpx/4320836036089189/3trk/000000/000000';
|
expect(id).toEqual({ gpx: 1, trk: 0, trkseg: 0 });
|
||||||
const idTrksegpt = 'gpx/4320836036089189/3trk/000000/000000/000035';
|
|
||||||
const trkpt3: Wpt = {
|
|
||||||
$: { lat: 3, lon: 3 },
|
|
||||||
};
|
|
||||||
const trkseg0: Trkseg = {
|
|
||||||
trkpt: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const trkseg1: Trkseg = {
|
|
||||||
trkpt: [
|
|
||||||
{
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
},
|
|
||||||
trkpt3,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const trksegPut = await putTrkseg(idTrkseg, trkseg0);
|
|
||||||
await put(idTrksegpt, 'trkpt', () => trkpt3, emptyWpt);
|
|
||||||
expect(await getTrkseg({ id: idTrkseg })).toEqual(trkseg1);
|
|
||||||
compactRteOrTrkseg({ id: idTrkseg, getDocs: getTrksegDocs });
|
|
||||||
expect(await getTrkseg({ id: idTrkseg })).toEqual(trkseg1);
|
|
||||||
});
|
});
|
||||||
it('can compact external trkpts without existing internal trkpts', async () => {
|
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||||
const idTrkseg = 'gpx/4320836036089189/3trk/000000/000000';
|
const id = await putNewTrkseg();
|
||||||
const idTrksegpt1 = 'gpx/4320836036089189/3trk/000000/000000/000035';
|
expect(id).toEqual({ gpx: 4320000000000000, trk: 0, trkseg: 0 });
|
||||||
const idTrksegpt2 = 'gpx/4320836036089189/3trk/000000/000000/000036';
|
|
||||||
const trkpt1 = {
|
|
||||||
$: { lat: 1, lon: 1 },
|
|
||||||
};
|
|
||||||
const trkpt2 = {
|
|
||||||
$: { lat: 2, lon: 2 },
|
|
||||||
};
|
|
||||||
const trkseg0: Trkseg = {};
|
|
||||||
const trkseg1: Trkseg = {
|
|
||||||
trkpt: [trkpt1, trkpt2],
|
|
||||||
};
|
|
||||||
const trksegPut = await putTrkseg(idTrkseg, trkseg0);
|
|
||||||
await put(idTrksegpt1, 'trkpt', () => trkpt1, emptyWpt);
|
|
||||||
await put(idTrksegpt2, 'trkpt', () => trkpt2, emptyWpt);
|
|
||||||
const { trkseg, docs } = await getTrksegDocs({ id: idTrkseg });
|
|
||||||
expect(trkseg).toEqual(trkseg1);
|
|
||||||
expect(docs.rows.length).toEqual(3);
|
|
||||||
await compactRteOrTrkseg({ id: idTrkseg, getDocs: getTrksegDocs });
|
|
||||||
//await sleep(5000);
|
|
||||||
const { trkseg: trksegx, docs: docsx } = await getTrksegDocs({
|
|
||||||
id: idTrkseg,
|
|
||||||
});
|
|
||||||
expect(trksegx).toEqual(trkseg1);
|
|
||||||
expect(docsx.rows.length).toEqual(1);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import { cloneDeep } from 'lodash';
|
|
||||||
import { state } from '../db-admin/health-legacy';
|
|
||||||
import getUri, { intToTrkptId } from '../lib/ids';
|
import getUri, { intToTrkptId } from '../lib/ids';
|
||||||
import { appendToArray } from './gpx';
|
import { appendToArray } from './gpx';
|
||||||
import { getFamily, put } from './lib';
|
import { getFamily, put } from './lib';
|
||||||
import { compactRteOrTrksegDebounced } from './rte';
|
|
||||||
import { putNewTrk } from './trk';
|
import { putNewTrk } from './trk';
|
||||||
import { emptyWpt } from './wpt';
|
import { emptyWpt } from './wpt';
|
||||||
|
|
||||||
|
@ -12,45 +9,55 @@ const emptyTrkseg: Trkseg = {
|
||||||
extensions: undefined,
|
extensions: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getTrksegDocs: ({
|
export const putNewTrkseg = async (id?: IdTrk | IdGpx | IdTrkseg) => {
|
||||||
id,
|
let finalId = { ...id };
|
||||||
}: {
|
if (!('trkseg' in finalId)) {
|
||||||
id: string;
|
const trkId = await putNewTrk(id);
|
||||||
}) => Promise<{ docs: any; trkseg: Trkseg }> = async (params) => {
|
finalId = { ...trkId, trkseg: 0 };
|
||||||
const { id } = params;
|
|
||||||
const docs = await getFamily(id, { include_docs: true });
|
|
||||||
let trkseg: Trkseg;
|
|
||||||
if (docs.rows.length === 1) {
|
|
||||||
trkseg = docs.rows[0].doc.doc;
|
|
||||||
} else {
|
|
||||||
trkseg = cloneDeep(docs.rows[0].doc.doc);
|
|
||||||
if (!trkseg.trkpt) {
|
|
||||||
trkseg.trkpt = [];
|
|
||||||
}
|
|
||||||
docs.rows.slice(1).forEach((row: any) => {
|
|
||||||
trkseg.trkpt.push(row.doc.doc);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
console.log({
|
const uri = getUri('trkseg', finalId);
|
||||||
caller: 'getTrksegDocs',
|
await put(
|
||||||
id,
|
uri,
|
||||||
docs,
|
'trkseg',
|
||||||
nbWptIn: docs.rows[0].doc.doc.trkpt?.length,
|
(trkseg) => {
|
||||||
nbWptTotal: trkseg?.trkpt?.length,
|
return trkseg;
|
||||||
});
|
},
|
||||||
return { docs, trkseg };
|
emptyTrkseg
|
||||||
|
);
|
||||||
|
return finalId as IdTrkseg;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getTrkseg = async (params: any) => {
|
export const getTrkseg = async (params: any) => {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { docs, trkseg } = await getTrksegDocs(params);
|
const docs = await getFamily(id, { include_docs: true });
|
||||||
if (docs.rows.length > 1 && docs.rows[0].doc.origin === state().userId) {
|
let target: any[];
|
||||||
// console.log({
|
let trkseg: Trkseg | undefined = undefined;
|
||||||
// caller: 'getTrkseg compactRteOrTrksegDebounced required',
|
docs.rows.every((row: any) => {
|
||||||
// id,
|
// level 0
|
||||||
// });
|
if (row.doc.type === 'trkseg') {
|
||||||
compactRteOrTrksegDebounced({ id, getDocs: getTrksegDocs });
|
if (!!trkseg) {
|
||||||
}
|
console.error({
|
||||||
|
caller: 'getTrkseg',
|
||||||
|
id,
|
||||||
|
row,
|
||||||
|
target,
|
||||||
|
trkseg,
|
||||||
|
});
|
||||||
|
|
||||||
|
return false; // Hack to stop if getFamily fails
|
||||||
|
}
|
||||||
|
target = [row.doc.doc];
|
||||||
|
trkseg = row.doc.doc;
|
||||||
|
}
|
||||||
|
//level 1
|
||||||
|
if (row.doc.type === 'trkpt') {
|
||||||
|
target.splice(1);
|
||||||
|
row.doc.doc.id = row.doc._id;
|
||||||
|
appendToArray(target.at(-1), row.doc.type, row.doc.doc);
|
||||||
|
target.push(row.doc.doc);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
return trkseg;
|
return trkseg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -49,13 +49,7 @@ interface Extensions {
|
||||||
'dyo:batterylevel'?: number;
|
'dyo:batterylevel'?: number;
|
||||||
'dyo:useragent'?: string;
|
'dyo:useragent'?: string;
|
||||||
'dyo:minZoom'?: number;
|
'dyo:minZoom'?: number;
|
||||||
address?: any;
|
address: any;
|
||||||
to?: string;
|
|
||||||
startTime?: string;
|
|
||||||
endTime?: string;
|
|
||||||
category?: Category;
|
|
||||||
subCategory?: SubCategory;
|
|
||||||
tags?: any;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Trk {
|
interface Trk {
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
import { putNewWpt } from './wpt';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
var db: any;
|
||||||
|
var dbReady: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const originalDb = globalThis.db;
|
||||||
|
const originalDateNow = globalThis.Date.now;
|
||||||
|
|
||||||
|
describe('The wpt module', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
globalThis.db = { put: jest.fn() };
|
||||||
|
globalThis.Date.now = () => 0;
|
||||||
|
});
|
||||||
|
afterEach(() => {
|
||||||
|
globalThis.db = originalDb;
|
||||||
|
globalThis.Date.now = originalDateNow;
|
||||||
|
});
|
||||||
|
test('db.put() a new wpt when required', async () => {
|
||||||
|
putNewWpt({ gpx: 1, wpt: 2 });
|
||||||
|
await expect(globalThis.db.put).toBeCalledWith({
|
||||||
|
_id: 'gpx/0000000000000001/1wpt/000002',
|
||||||
|
_rev: undefined,
|
||||||
|
doc: {
|
||||||
|
$: { lat: 0, lon: 0 },
|
||||||
|
ageofdgpsdata: undefined,
|
||||||
|
cmt: undefined,
|
||||||
|
desc: undefined,
|
||||||
|
dgpsid: undefined,
|
||||||
|
ele: undefined,
|
||||||
|
extensions: undefined,
|
||||||
|
fix: undefined,
|
||||||
|
geoidheight: undefined,
|
||||||
|
hdop: undefined,
|
||||||
|
link: undefined,
|
||||||
|
magvar: undefined,
|
||||||
|
name: undefined,
|
||||||
|
pdop: undefined,
|
||||||
|
sat: undefined,
|
||||||
|
src: undefined,
|
||||||
|
sym: undefined,
|
||||||
|
time: undefined,
|
||||||
|
type: undefined,
|
||||||
|
vdop: undefined,
|
||||||
|
},
|
||||||
|
type: 'wpt',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('db.put() generates an id for the wpt if needed', async () => {
|
||||||
|
const id = await putNewWpt({ gpx: 1 });
|
||||||
|
expect(id).toEqual({ gpx: 1, wpt: 0 });
|
||||||
|
});
|
||||||
|
test('db.put() generates ids for both gpx and trk if needed', async () => {
|
||||||
|
const id = await putNewWpt();
|
||||||
|
expect(id).toEqual({ gpx: 4320000000000000, wpt: 0 });
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,6 +1,6 @@
|
||||||
import getUri from '../lib/ids';
|
import getUri from '../lib/ids';
|
||||||
import { putNewGpx } from './gpx';
|
import { putNewGpx } from './gpx';
|
||||||
import { get, getFamily, put } from './lib';
|
import { get, put } from './lib';
|
||||||
|
|
||||||
export const emptyWpt: Wpt = {
|
export const emptyWpt: Wpt = {
|
||||||
$: { lat: 0, lon: 0 },
|
$: { lat: 0, lon: 0 },
|
||||||
|
@ -62,17 +62,3 @@ export const getWpt = async (params: any) => {
|
||||||
const doc = await get(id);
|
const doc = await get(id);
|
||||||
return doc.doc;
|
return doc.doc;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteWpt = async (params: any) => {
|
|
||||||
const { id } = params;
|
|
||||||
const docs = await getFamily(id, { include_docs: false });
|
|
||||||
console.log({ caller: 'deleteWpt' }, id, docs);
|
|
||||||
const deletedDocs = docs.rows.reverse().map((doc: any) => ({
|
|
||||||
_deleted: true,
|
|
||||||
_id: doc.id,
|
|
||||||
_rev: doc.value.rev,
|
|
||||||
}));
|
|
||||||
console.log({ caller: 'deleteWpt' }, id, docs, deletedDocs);
|
|
||||||
await db.bulkDocs(deletedDocs);
|
|
||||||
return id;
|
|
||||||
};
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ const dict = {
|
||||||
gpxNoName: 'No name',
|
gpxNoName: 'No name',
|
||||||
gpxDesc: 'Description',
|
gpxDesc: 'Description',
|
||||||
gpxTime: 'Start date',
|
gpxTime: 'Start date',
|
||||||
gpxTo: 'To',
|
|
||||||
gpxSave: 'Save',
|
gpxSave: 'Save',
|
||||||
newGpx: '-- new journey --',
|
newGpx: '-- new journey --',
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ const dict = {
|
||||||
gpxNoName: 'Pas de nom',
|
gpxNoName: 'Pas de nom',
|
||||||
gpxDesc: 'Description',
|
gpxDesc: 'Description',
|
||||||
gpxTime: 'Date de début',
|
gpxTime: 'Date de début',
|
||||||
gpxTo: 'Destinataires',
|
|
||||||
gpxSave: 'Sauvegarder',
|
gpxSave: 'Sauvegarder',
|
||||||
newGpx: '-- nouveau voyage --',
|
newGpx: '-- nouveau voyage --',
|
||||||
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
|
||||||
<svg width="800px" height="800px" viewBox="0 0 17 17" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="si-glyph si-glyph-bicycle-man">
|
|
||||||
<title>1102</title>
|
|
||||||
<defs>
|
|
||||||
</defs>
|
|
||||||
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
||||||
<g transform="translate(1.000000, 2.000000)" fill="#434343">
|
|
||||||
<path d="M8.5,12.969 C8.141,12.967 8.005,12.68 8.006,12.316 L8.021,9.532 L5.153,6.44 C4.934,6.151 4.99,5.737 5.274,5.515 L8.836,2.582 C8.972,2.477 9.147,2.428 9.316,2.451 C9.486,2.473 9.641,2.564 9.746,2.703 L11.29,4.508 L13.579,5.605 C13.914,5.735 14.083,6.116 13.956,6.457 C13.828,6.798 13.453,6.97 13.117,6.84 L10.656,5.677 C10.543,5.633 10.445,5.56 10.371,5.462 L9.111,4.033 L6.687,6.16 L8.878,8.698 C8.964,8.814 8.968,8.912 8.968,9.058 L8.985,12.312 C8.984,12.676 8.859,12.97 8.5,12.969 L8.5,12.969 L8.5,12.969 Z" class="si-glyph-fill">
|
|
||||||
</path>
|
|
||||||
<g transform="translate(0.000000, 8.000000)">
|
|
||||||
<path d="M12.98,-0.018 C11.335,-0.018 10.003,1.326 10.003,2.983 C10.003,4.64 11.335,5.984 12.98,5.984 C14.625,5.984 15.958,4.64 15.958,2.983 C15.958,1.326 14.625,-0.018 12.98,-0.018 L12.98,-0.018 Z M12.975,5.046 C11.83,5.046 10.903,4.123 10.903,2.984 C10.903,1.845 11.831,0.922 12.975,0.922 C14.116,0.922 15.044,1.845 15.044,2.984 C15.044,4.123 14.115,5.046 12.975,5.046 L12.975,5.046 Z" class="si-glyph-fill">
|
|
||||||
</path>
|
|
||||||
<path d="M2.991,0.023 C1.349,0.023 0.02,1.353 0.02,2.994 C0.02,4.636 1.349,5.965 2.991,5.965 C4.631,5.965 5.962,4.636 5.962,2.994 C5.962,1.354 4.631,0.023 2.991,0.023 L2.991,0.023 Z M2.991,5.063 C1.847,5.063 0.922,4.137 0.922,2.994 C0.922,1.851 1.848,0.925 2.991,0.925 C4.133,0.925 5.06,1.851 5.06,2.994 C5.06,4.137 4.133,5.063 2.991,5.063 L2.991,5.063 Z" class="si-glyph-fill">
|
|
||||||
</path>
|
|
||||||
</g>
|
|
||||||
<ellipse cx="11.469" cy="1.486" rx="1.469" ry="1.486" class="si-glyph-fill">
|
|
||||||
</ellipse>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 2.0 KiB |
|
@ -1,2 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
|
||||||
<svg width="800px" height="800px" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--gis" preserveAspectRatio="xMidYMid meet"><path d="M46.43 7.5c4.055 0 7.337 3.379 7.337 7.434c0 4.054-3.282 7.433-7.337 7.433s-7.434-3.379-7.434-7.433c0-4.055 3.38-7.434 7.434-7.434zm.483 15.543c2.79-.087 4.947 1.649 6.082 3.476l7.723 12.84l13.516 5.696c3.861 1.64 2.027 6.757-2.317 5.599a5.015 5.015 0 0 0-.483-.29l-9.075 20.08s2.896 6.662 6.565 14.193c3.572 7.626-5.117 10.909-8.303 3.861l-3.185-7.144l-4.634 10.137l-1.931-.869l5.406-11.778l-9.075-19.79c-.386.096-.772 0-1.255 0c0 0-10.523 23.941-13.42 30.217c-2.799 6.275-11.101 2.51-8.302-3.67c2.8-6.178 16.123-36.202 16.123-36.202l-9.903.162c-1.5.013-1.859-.226-1.954-1.35c-.153-2.97-.415-9.958.272-13.197c.886-4.175 1.415-8.77 4.344-10.137c2.93-1.367 8.013 2.414 8.013 2.414c.772-2.51 3.186-4.248 5.793-4.248zm5.985 15.06V49.69l8.303 18.15l8.302-18.247l-12.067-5.02c-.58-.29-1.062-.676-1.449-1.255z" fill="#000000" fill-rule="evenodd"></path></svg>
|
|
Before Width: | Height: | Size: 1.2 KiB |
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
|
||||||
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path d="M20 14V7C20 5.34315 18.6569 4 17 4H7C5.34315 4 4 5.34315 4 7V17C4 18.6569 5.34315 20 7 20H13.5M20 14L13.5 20M20 14H15.5C14.3954 14 13.5 14.8954 13.5 16V20" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
<path d="M8 8H16" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
<path d="M8 12H12" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 683 B |
|
@ -1,168 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
<svg
|
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
||||||
xmlns:cc="http://web.resource.org/cc/"
|
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
version="1.0"
|
|
||||||
width="480"
|
|
||||||
height="480"
|
|
||||||
id="svg2"
|
|
||||||
sodipodi:version="0.32"
|
|
||||||
inkscape:version="0.45.1"
|
|
||||||
sodipodi:docname="bike.svg"
|
|
||||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
|
||||||
sodipodi:docbase="C:\Dokumente und Einstellungen\ulfl\Eigene Dateien\svn.openstreetmap.org\applications\share\map-icons\svg\vehicle\parking">
|
|
||||||
<metadata
|
|
||||||
id="metadata8">
|
|
||||||
<rdf:RDF>
|
|
||||||
<cc:Work
|
|
||||||
rdf:about="">
|
|
||||||
<dc:format>image/svg+xml</dc:format>
|
|
||||||
<dc:type
|
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
||||||
<cc:license
|
|
||||||
rdf:resource="http://web.resource.org/cc/PublicDomain" />
|
|
||||||
</cc:Work>
|
|
||||||
<cc:License
|
|
||||||
rdf:about="http://web.resource.org/cc/PublicDomain">
|
|
||||||
<cc:permits
|
|
||||||
rdf:resource="http://web.resource.org/cc/Reproduction" />
|
|
||||||
<cc:permits
|
|
||||||
rdf:resource="http://web.resource.org/cc/Distribution" />
|
|
||||||
<cc:permits
|
|
||||||
rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
|
|
||||||
</cc:License>
|
|
||||||
</rdf:RDF>
|
|
||||||
</metadata>
|
|
||||||
<sodipodi:namedview
|
|
||||||
inkscape:window-height="573"
|
|
||||||
inkscape:window-width="797"
|
|
||||||
inkscape:pageshadow="2"
|
|
||||||
inkscape:pageopacity="0.0"
|
|
||||||
guidetolerance="10.0"
|
|
||||||
gridtolerance="10.0"
|
|
||||||
objecttolerance="10.0"
|
|
||||||
borderopacity="1.0"
|
|
||||||
bordercolor="#666666"
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
id="base"
|
|
||||||
inkscape:zoom="0.78541667"
|
|
||||||
inkscape:cx="240"
|
|
||||||
inkscape:cy="240"
|
|
||||||
inkscape:window-x="154"
|
|
||||||
inkscape:window-y="203"
|
|
||||||
inkscape:current-layer="svg2" />
|
|
||||||
<defs
|
|
||||||
id="defs4">
|
|
||||||
<marker
|
|
||||||
viewBox="0 0 10 10"
|
|
||||||
refY="5"
|
|
||||||
refX="10"
|
|
||||||
orient="auto"
|
|
||||||
markerWidth="4"
|
|
||||||
markerUnits="strokeWidth"
|
|
||||||
markerHeight="3"
|
|
||||||
id="ArrowStart">
|
|
||||||
<path
|
|
||||||
id="path2295"
|
|
||||||
d="M 10,0 L 0,5 L 10,10 L 10,0 z " />
|
|
||||||
</marker>
|
|
||||||
<marker
|
|
||||||
viewBox="0 0 10 10"
|
|
||||||
refY="5"
|
|
||||||
refX="0"
|
|
||||||
orient="auto"
|
|
||||||
markerWidth="4"
|
|
||||||
markerUnits="strokeWidth"
|
|
||||||
markerHeight="3"
|
|
||||||
id="ArrowEnd">
|
|
||||||
<path
|
|
||||||
id="path2292"
|
|
||||||
d="M 0,0 L 10,5 L 0,10 L 0,0 z " />
|
|
||||||
</marker>
|
|
||||||
</defs>
|
|
||||||
<path
|
|
||||||
d="M 30.856274,5.7720243 L 450.86109,5.7720243 C 461.67691,6.5627045 473.93298,17.615789 474.52755,30.636789 L 474.52755,449.4433 C 474.57722,459.76184 462.73404,473.63554 449.36321,474.30807 L 29.957547,474.30807 C 20.433732,473.72489 5.5262338,458.92955 5.0927831,449.14373 L 5.691934,30.936364 C 4.6103723,24.633922 19.978002,5.6381226 30.856274,5.7720243 z "
|
|
||||||
style="fill:white;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path3669" />
|
|
||||||
<path
|
|
||||||
d="M 35.1875,16.78125 C 23.426887,16.266334 16.714331,24.30046 17.15625,37.15625 L 17.15625,443.5625 C 17.202803,452.2297 20.884421,462.63293 32.84375,462.84375 L 447.28125,462.8125 C 459.24058,462.6017 462.95345,452.19845 463,443.53125 L 463,37.09375 C 463.44191,24.237959 456.72937,16.20383 444.96875,16.71875 L 35.1875,16.78125 z "
|
|
||||||
style="fill:#039;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.94117647"
|
|
||||||
id="path3661" />
|
|
||||||
<path
|
|
||||||
d="M 100.82515,91.817251 L 100.82515,197.08323 L 174.28737,197.08323 C 192.65275,197.0834 206.35224,191.55881 215.3859,180.50943 C 224.41915,169.46044 228.93588,157.44072 228.93609,144.45024 C 228.93588,124.74111 221.8435,110.25772 207.65893,101.00002 C 198.55062,94.878451 186.82953,91.817521 172.49561,91.817251 L 100.82515,91.817251 z M 51.327737,371.33202 L 51.327737,45.00748 L 169.80797,45.00748 C 182.49944,45.007806 194.70581,46.351626 206.42709,49.038943 C 218.148,51.726905 230.35436,57.998063 243.04621,67.852438 C 252.90067,75.467721 261.26221,85.956981 268.13087,99.320251 C 274.99903,112.68406 278.43324,128.17531 278.4335,145.79406 C 278.43324,169.08716 269.73574,191.26018 252.34098,212.3132 C 234.94574,233.36653 209.52515,243.89312 176.07913,243.89299 L 100.82515,243.89299 L 100.82515,371.33202 L 51.327737,371.33202 z "
|
|
||||||
style="font-size:458.69091797px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:100%;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:DIN 1451 Mittelschrift"
|
|
||||||
id="text5426" />
|
|
||||||
<g
|
|
||||||
transform="matrix(0.7929425,0,0,0.7755778,-372.35858,292.1436)"
|
|
||||||
id="g2297">
|
|
||||||
<path
|
|
||||||
d="M 278.91286 461.96271 A 78.380615 78.380615 0 1 1 122.15163,461.96271 A 78.380615 78.380615 0 1 1 278.91286 461.96271 z"
|
|
||||||
id="path596"
|
|
||||||
sodipodi:cx="200.53224"
|
|
||||||
sodipodi:cy="461.96271"
|
|
||||||
sodipodi:rx="78.380615"
|
|
||||||
sodipodi:ry="78.380615"
|
|
||||||
sodipodi:type="arc"
|
|
||||||
style="font-size:12px;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:26;stroke-opacity:1"
|
|
||||||
transform="matrix(-0.7941975,0,0,0.7941975,844.6956,-247.27632)" />
|
|
||||||
<path
|
|
||||||
d="M 278.91286 461.96271 A 78.380615 78.380615 0 1 1 122.15163,461.96271 A 78.380615 78.380615 0 1 1 278.91286 461.96271 z"
|
|
||||||
id="path595"
|
|
||||||
sodipodi:cx="200.53224"
|
|
||||||
sodipodi:cy="461.96271"
|
|
||||||
sodipodi:rx="78.380615"
|
|
||||||
sodipodi:ry="78.380615"
|
|
||||||
sodipodi:type="arc"
|
|
||||||
style="font-size:12px;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#feffff;stroke-width:25.99983025;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
transform="matrix(-0.7941975,0,0,0.7941975,1111.4801,-248.48899)" />
|
|
||||||
<path
|
|
||||||
d="M 902.90325,12.49531 L 742.83259,13.303766 L 686.24197,118.40065 L 794.57261,118.40065 L 907.75387,41.599088"
|
|
||||||
id="path594"
|
|
||||||
sodipodi:nodetypes="ccccc"
|
|
||||||
style="font-size:12px;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:16.57887268;stroke-linejoin:round;stroke-opacity:1" />
|
|
||||||
<path
|
|
||||||
d="M 896.75233,-50.489179 C 905.44709,-50.489179 912.01918,-50.683176 918.75551,-40.392067 C 920.69453,-36.961461 921.58106,-32.77272 920.86509,-28.603196 C 920.00619,-23.862035 917.19925,-19.203901 913.89022,-16.4464 C 909.5085,-12.79494 905.35013,-13.076632 906.02217,-9.7941826 C 906.88446,-5.5824266 909.51604,0.27036544 912.35992,9.7741226 C 915.24666,19.42106 918.67449,31.227993 922.03921,42.857413 C 925.40393,54.486808 928.70687,65.944962 931.32138,74.873497 C 932.62866,79.337753 933.77035,83.171066 934.6471,86.041895 C 935.5013,88.83894 936.25548,91.011621 936.18584,90.856721 C 938.90979,95.649288 939.28057,98.772121 943.84948,102.85126 C 948.97222,107.33462 953.14308,110.64668 954.59062,111.65843 C 958.26729,114.32927 959.97652,119.96578 958.03499,122.75082 C 955.58819,126.54638 950.53489,127.12861 946.8416,125.99309 C 943.33471,124.87986 937.78337,122.96765 931.34621,117.63605 L 931.29657,117.56161 L 931.22211,117.51197 C 922.26513,109.82917 918.95144,100.50467 918.61424,99.965175 L 918.14268,99.245428 L 917.82003,98.451238 C 917.0439,96.540701 916.57901,94.856088 915.66081,91.849459 C 914.74261,88.842831 913.57861,84.958513 912.26065,80.457684 C 909.62473,71.456073 906.33855,59.980493 902.97847,48.367156 C 899.61837,36.753819 896.19895,25.006992 893.34882,15.482413 C 890.4987,5.9578348 888.69807,-1.8646344 888.03246,-3.528685 C 886.41239,-7.578844 885.58474,-11.951325 886.69224,-16.335124 C 887.79972,-20.718923 891.10922,-24.257008 894.08003,-25.079472 C 900.86114,-26.976615 899.06187,-31.854189 895.59257,-31.861264 L 866.5202,-31.920451 L 866.44854,-50.488779 C 866.44873,-50.489179 885.31934,-50.489179 896.75233,-50.489179 z "
|
|
||||||
id="path593"
|
|
||||||
sodipodi:nodetypes="ccccscccccsscsccccccccccccssccc"
|
|
||||||
style="font-size:12px;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke-width:25;stroke-linecap:round" />
|
|
||||||
<path
|
|
||||||
d="M 792.49843,115.11004 L 737.61984,-19.228118"
|
|
||||||
id="path599"
|
|
||||||
style="font-size:12px;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:19.85493851;stroke-opacity:1" />
|
|
||||||
<path
|
|
||||||
d="M 817.07944,72.236162 L 772.49063,166.5587"
|
|
||||||
id="path600"
|
|
||||||
style="font-size:12px;fill:#fffffd;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:7.24705219;stroke-linecap:round;stroke-opacity:1" />
|
|
||||||
<path
|
|
||||||
d="M 278.91286 461.96271 A 78.380615 78.380615 0 1 1 122.15163,461.96271 A 78.380615 78.380615 0 1 1 278.91286 461.96271 z"
|
|
||||||
id="path597"
|
|
||||||
sodipodi:cx="200.53224"
|
|
||||||
sodipodi:cy="461.96271"
|
|
||||||
sodipodi:rx="78.380615"
|
|
||||||
sodipodi:ry="78.380615"
|
|
||||||
sodipodi:type="arc"
|
|
||||||
style="font-size:12px;fill:#fffeff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:31.30500031;stroke-opacity:1"
|
|
||||||
transform="matrix(-0.3120051,0,0,0.3223192,856.53347,-30.297359)" />
|
|
||||||
<path
|
|
||||||
d="M 828.98308,75.129086 L 799.69311,75.397573"
|
|
||||||
id="path601"
|
|
||||||
sodipodi:nodetypes="cc"
|
|
||||||
style="font-size:12px;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:10.12601757;stroke-opacity:1" />
|
|
||||||
<path
|
|
||||||
d="M 787.42188,162.59237 L 758.13191,162.86086"
|
|
||||||
id="path602"
|
|
||||||
sodipodi:nodetypes="cc"
|
|
||||||
style="font-size:12px;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:10.12601757;stroke-opacity:1" />
|
|
||||||
<path
|
|
||||||
d="M 710.75194,-31.233245 L 779.63603,-31.233245 C 782.20847,-31.233245 785.5287,-26.682779 782.20847,-23.658842 C 778.6175,-20.24123 746.33729,-13.226203 746.33729,-13.226203 C 746.33729,-13.226203 737.47669,-10.796683 732.76054,-11.368321 C 728.04443,-11.939982 711.75234,-13.369101 710.75194,-31.233245 z "
|
|
||||||
id="path603"
|
|
||||||
sodipodi:nodetypes="cssccc"
|
|
||||||
style="font-size:12px;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.79419751pt;stroke-opacity:1" />
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 10 KiB |
|
@ -1,111 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
<svg
|
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
||||||
xmlns:cc="http://web.resource.org/cc/"
|
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
version="1.0"
|
|
||||||
width="480"
|
|
||||||
height="720"
|
|
||||||
id="svg2"
|
|
||||||
sodipodi:version="0.32"
|
|
||||||
inkscape:version="0.45.1"
|
|
||||||
sodipodi:docname="hiking.svg"
|
|
||||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
|
||||||
sodipodi:docbase="G:\Documents\map-icons\svg\vehicle\parking">
|
|
||||||
<metadata
|
|
||||||
id="metadata2495">
|
|
||||||
<rdf:RDF>
|
|
||||||
<cc:Work
|
|
||||||
rdf:about="">
|
|
||||||
<dc:format>image/svg+xml</dc:format>
|
|
||||||
<dc:type
|
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
||||||
<cc:license
|
|
||||||
rdf:resource="http://web.resource.org/cc/PublicDomain" />
|
|
||||||
</cc:Work>
|
|
||||||
<cc:License
|
|
||||||
rdf:about="http://web.resource.org/cc/PublicDomain">
|
|
||||||
<cc:permits
|
|
||||||
rdf:resource="http://web.resource.org/cc/Reproduction" />
|
|
||||||
<cc:permits
|
|
||||||
rdf:resource="http://web.resource.org/cc/Distribution" />
|
|
||||||
<cc:permits
|
|
||||||
rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
|
|
||||||
</cc:License>
|
|
||||||
</rdf:RDF>
|
|
||||||
</metadata>
|
|
||||||
<sodipodi:namedview
|
|
||||||
inkscape:window-height="573"
|
|
||||||
inkscape:window-width="797"
|
|
||||||
inkscape:pageshadow="2"
|
|
||||||
inkscape:pageopacity="0.0"
|
|
||||||
guidetolerance="10.0"
|
|
||||||
gridtolerance="10.0"
|
|
||||||
objecttolerance="10.0"
|
|
||||||
borderopacity="1.0"
|
|
||||||
bordercolor="#666666"
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
id="base"
|
|
||||||
inkscape:zoom="0.52361111"
|
|
||||||
inkscape:cx="240"
|
|
||||||
inkscape:cy="360"
|
|
||||||
inkscape:window-x="198"
|
|
||||||
inkscape:window-y="261"
|
|
||||||
inkscape:current-layer="svg2" />
|
|
||||||
<defs
|
|
||||||
id="defs4" />
|
|
||||||
<path
|
|
||||||
d="M 30.856274,5.7720243 L 450.86109,5.7720243 C 461.67691,6.5627045 473.93298,17.615789 474.52755,30.636789 L 474.52755,686.44619 C 474.57722,696.76473 462.73404,710.63843 449.36321,711.31096 L 29.957547,711.31096 C 20.433732,710.72778 5.5262338,695.93244 5.0927831,686.14662 L 5.691934,30.936364 C 5.4925171,19.341053 19.978002,5.6381226 30.856274,5.7720243 z "
|
|
||||||
style="fill:white;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path3669" />
|
|
||||||
<path
|
|
||||||
d="M 35.1875,16.78125 C 23.426887,16.266334 16.714331,24.30046 17.15625,37.15625 L 17.15625,680 C 17.202803,688.6672 20.884421,699.07046 32.84375,699.28125 L 447.28125,699.8125 C 459.24058,699.60169 462.95345,689.19845 463,680.53125 L 463,37.09375 C 463.44191,24.237959 456.72937,16.20383 444.96875,16.71875 L 35.1875,16.78125 z "
|
|
||||||
style="fill:#039;fill-opacity:1;fill-rule:evenodd;stroke:#00339f;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.94117647"
|
|
||||||
id="path2774" />
|
|
||||||
<path
|
|
||||||
d="M 97.67666,336.42028 L 97.626101,619.68454 L 382.40713,619.63398 L 382.40713,336.31916 L 97.67666,336.42028 z "
|
|
||||||
style="fill:white;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
|
||||||
id="path1886" />
|
|
||||||
<path
|
|
||||||
d="M 136.54347,86.246749 L 136.54347,169.00552 L 194.29853,169.00552 C 208.73716,169.00566 219.50752,164.66229 226.60967,155.97541 C 233.7115,147.28884 237.26249,137.83909 237.26266,127.62613 C 237.26249,112.13107 231.68655,100.74441 220.53482,93.466129 C 213.37399,88.653429 204.15902,86.246969 192.88987,86.246749 L 136.54347,86.246749 z M 97.629241,305.9977 L 97.629241,49.445505 L 190.77688,49.445505 C 200.75476,49.445762 210.35124,50.502256 219.56637,52.61499 C 228.78119,54.728231 238.37768,59.658536 248.35585,67.40592 C 256.1033,73.392957 262.67704,81.639479 268.07709,92.145509 C 273.47675,102.65197 276.17668,114.831 276.17689,128.68263 C 276.17668,146.99537 269.33882,164.42752 255.66328,180.97913 C 241.98737,197.53099 222.00202,205.80686 195.70719,205.80676 L 136.54347,205.80676 L 136.54347,305.9977 L 97.629241,305.9977 z "
|
|
||||||
style="font-size:360.61694336px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:100%;writing-mode:lr-tb;text-anchor:middle;fill:white;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:DIN 1451 Mittelschrift"
|
|
||||||
id="text1885" />
|
|
||||||
<g
|
|
||||||
style="fill:black"
|
|
||||||
id="g1967">
|
|
||||||
<path
|
|
||||||
d="M 305.47137,379.90744 C 305.47137,390.6016 296.80202,399.27096 286.10786,399.27096 C 275.41368,399.27096 266.74434,390.6016 266.74434,379.90744 C 266.74434,369.21326 275.41368,360.54391 286.10786,360.54391 C 296.80202,360.54391 305.47137,369.21326 305.47137,379.90744 L 305.47137,379.90744 z "
|
|
||||||
style="fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
|
||||||
id="path5663" />
|
|
||||||
<path
|
|
||||||
d="M 276.52373,494.9308 L 315.00347,494.9308 L 315.18137,498.39434 L 356.02613,574.90167 C 356.82547,587.40818 351.13058,592.20279 345.42581,596.98566 L 295.95765,505.99959 L 248.25621,591.24383 C 234.77599,599.77637 229.81923,596.19662 223.96382,593.8939 L 276.15963,499.07994 L 276.52373,494.9308 z "
|
|
||||||
style="fill:black;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
|
||||||
id="path5659" />
|
|
||||||
<path
|
|
||||||
d="M 252.0663,477.51136 L 275.68305,454.10216 L 275.27572,414.41829 C 281.15774,406.61054 291.33339,402.78549 305.93992,406.61042 L 347.85266,471.57304 C 347.21135,479.98392 346.89804,489.73908 338.19975,489.68581 L 314.56004,450.92359 L 314.06048,490.37335 L 275.89608,490.40536 L 275.66622,478.0085 C 276.07919,479.79802 259.01884,488.86597 252.0663,477.51136 z "
|
|
||||||
style="opacity:1;fill:black;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
|
||||||
id="path5661" />
|
|
||||||
<g
|
|
||||||
transform="translate(525.4094,-19.18652)"
|
|
||||||
style="fill:black"
|
|
||||||
id="g1954">
|
|
||||||
<path
|
|
||||||
d="M -315.45043,399.09396 C -315.45043,409.78812 -324.11978,418.45748 -334.81394,418.45748 C -345.50812,418.45748 -354.17746,409.78812 -354.17746,399.09396 C -354.17746,388.39978 -345.50812,379.73043 -334.81394,379.73043 C -324.11978,379.73043 -315.45043,388.39978 -315.45043,399.09396 L -315.45043,399.09396 z "
|
|
||||||
style="fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
|
||||||
id="path1956" />
|
|
||||||
<path
|
|
||||||
d="M -344.39807,514.11732 L -305.91833,514.11732 L -305.74043,517.58086 L -264.89567,594.08819 C -264.09633,606.5947 -269.79122,611.38931 -275.49599,616.17218 L -324.96415,525.18611 L -372.66559,610.43035 C -386.14581,618.96289 -391.10257,615.38314 -396.95798,613.08042 L -344.76217,518.26646 L -344.39807,514.11732 z "
|
|
||||||
style="fill:black;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
|
||||||
id="path1958" />
|
|
||||||
<path
|
|
||||||
d="M -399.83568,473.09124 L -345.08881,430.74432 C -337.89231,423.54782 -329.58841,421.97201 -314.98188,425.79694 L -281.12568,452.53244 L -277.06558,460.028 L -277.06558,487.76223 C -280.75825,495.60098 -286.03713,500.92821 -294.71137,500.87945 L -294.71137,464.55657 L -305.61243,455.62301 L -305.61243,509.80965 L -344.80795,509.80965 L -344.80795,452.21584 L -381.34993,482.27214 L -311.98699,611.13555 L -320.37358,616.2234 L -392.05517,486.92262 C -397.14454,490.55788 -404.80356,477.35337 -399.83568,473.09124 z "
|
|
||||||
style="fill:black;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
|
||||||
id="path1960" />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 8.0 KiB |
|
@ -1,74 +1 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<svg xmlns="http://www.w3.org/2000/svg" width="580" height="580" xml:space="preserve"><path fill="#0071BC" stroke="#0071BC" stroke-width=".5" d="M500.742 278.013v-12.462h4.701c.829 0 1.459.04 1.896.119.611.102 1.124.296 1.537.583.414.286.748.687 1 1.202a3.85 3.85 0 0 1 .378 1.7c0 1.061-.337 1.957-1.012 2.691-.674.734-1.895 1.101-3.656 1.101h-3.196v5.066h-1.648zm1.651-6.537h3.222c1.064 0 1.821-.198 2.271-.595.445-.397.669-.955.669-1.675 0-.521-.131-.968-.393-1.338a1.846 1.846 0 0 0-1.042-.735c-.278-.074-.79-.11-1.538-.11h-3.188v4.453h-.001z"/></svg>
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
<svg
|
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
||||||
xmlns:cc="http://web.resource.org/cc/"
|
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
version="1.0"
|
|
||||||
width="480"
|
|
||||||
height="480"
|
|
||||||
id="svg2"
|
|
||||||
sodipodi:version="0.32"
|
|
||||||
inkscape:version="0.45.1"
|
|
||||||
sodipodi:docname="parking.svg"
|
|
||||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
|
||||||
sodipodi:docbase="C:\Dokumente und Einstellungen\ulfl\Eigene Dateien\svn.openstreetmap.org\applications\share\map-icons\svg\vehicle">
|
|
||||||
<metadata
|
|
||||||
id="metadata8">
|
|
||||||
<rdf:RDF>
|
|
||||||
<cc:Work
|
|
||||||
rdf:about="">
|
|
||||||
<dc:format>image/svg+xml</dc:format>
|
|
||||||
<dc:type
|
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
||||||
<cc:license
|
|
||||||
rdf:resource="http://web.resource.org/cc/PublicDomain" />
|
|
||||||
</cc:Work>
|
|
||||||
<cc:License
|
|
||||||
rdf:about="http://web.resource.org/cc/PublicDomain">
|
|
||||||
<cc:permits
|
|
||||||
rdf:resource="http://web.resource.org/cc/Reproduction" />
|
|
||||||
<cc:permits
|
|
||||||
rdf:resource="http://web.resource.org/cc/Distribution" />
|
|
||||||
<cc:permits
|
|
||||||
rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
|
|
||||||
</cc:License>
|
|
||||||
</rdf:RDF>
|
|
||||||
</metadata>
|
|
||||||
<sodipodi:namedview
|
|
||||||
inkscape:window-height="573"
|
|
||||||
inkscape:window-width="797"
|
|
||||||
inkscape:pageshadow="2"
|
|
||||||
inkscape:pageopacity="0.0"
|
|
||||||
guidetolerance="10.0"
|
|
||||||
gridtolerance="10.0"
|
|
||||||
objecttolerance="10.0"
|
|
||||||
borderopacity="1.0"
|
|
||||||
bordercolor="#666666"
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
id="base"
|
|
||||||
inkscape:zoom="0.78541667"
|
|
||||||
inkscape:cx="240"
|
|
||||||
inkscape:cy="240"
|
|
||||||
inkscape:window-x="154"
|
|
||||||
inkscape:window-y="203"
|
|
||||||
inkscape:current-layer="svg2" />
|
|
||||||
<defs
|
|
||||||
id="defs4" />
|
|
||||||
<path
|
|
||||||
d="M 30.856274,5.7720243 L 450.86109,5.7720243 C 461.67691,6.5627045 473.93298,17.615789 474.52755,30.636789 L 474.52755,449.4433 C 474.57722,459.76184 462.73404,473.63554 449.36321,474.30807 L 29.957547,474.30807 C 20.433732,473.72489 5.5262338,458.92955 5.0927831,449.14373 L 5.691934,30.936364 C 4.6103723,24.633922 19.978002,5.6381226 30.856274,5.7720243 z "
|
|
||||||
style="fill:white;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path3669" />
|
|
||||||
<path
|
|
||||||
d="M 35.1875,16.78125 C 23.426887,16.266334 16.714331,24.30046 17.15625,37.15625 L 17.15625,443.5625 C 17.202803,452.2297 20.884421,462.63293 32.84375,462.84375 L 447.28125,462.8125 C 459.24058,462.6017 462.95345,452.19845 463,443.53125 L 463,37.09375 C 463.44191,24.237959 456.72937,16.20383 444.96875,16.71875 L 35.1875,16.78125 z "
|
|
||||||
style="fill:#039;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.94117647"
|
|
||||||
id="path3661" />
|
|
||||||
<path
|
|
||||||
d="M 175.94451,123.64749 L 175.94451,228.91347 L 249.40673,228.91347 C 267.77211,228.91364 281.4716,223.38905 290.50526,212.33967 C 299.53851,201.29068 304.05524,189.27096 304.05545,176.28048 C 304.05524,156.57135 296.96286,142.08796 282.77829,132.83026 C 273.66998,126.70869 261.94889,123.64776 247.61497,123.64749 L 175.94451,123.64749 z M 126.4471,403.16226 L 126.4471,76.837719 L 244.92733,76.837719 C 257.6188,76.838045 269.82517,78.181865 281.54645,80.869182 C 293.26736,83.557144 305.47372,89.828302 318.16557,99.682677 C 328.02003,107.29796 336.38157,117.78722 343.25023,131.15049 C 350.11839,144.5143 353.5526,160.00555 353.55286,177.6243 C 353.5526,200.9174 344.8551,223.09042 327.46034,244.14344 C 310.0651,265.19677 284.64451,275.72336 251.19849,275.72323 L 175.94451,275.72323 L 175.94451,403.16226 L 126.4471,403.16226 z "
|
|
||||||
style="font-size:458.69091797px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:100%;writing-mode:lr-tb;text-anchor:middle;fill:white;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:DIN 1451 Mittelschrift"
|
|
||||||
id="text5426" />
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 554 B |
|
@ -1,13 +1,15 @@
|
||||||
/* @refresh reload */
|
/* @refresh reload */
|
||||||
import { render } from 'solid-js/web';
|
import { render } from 'solid-js/web';
|
||||||
import { Router } from '@solidjs/router';
|
import { Router, hashIntegration } from '@solidjs/router';
|
||||||
import {
|
import {
|
||||||
I18nContext,
|
I18nContext,
|
||||||
createI18nContext,
|
createI18nContext,
|
||||||
|
useI18n,
|
||||||
} from '@solid-primitives/i18n';
|
} from '@solid-primitives/i18n';
|
||||||
import dict from './i18n';
|
import dict from './i18n';
|
||||||
|
|
||||||
import App from './App';
|
import App from './App';
|
||||||
|
import { Language } from '@suid/icons-material';
|
||||||
|
|
||||||
// See https://stackoverflow.com/questions/71538643/property-wakelock-does-not-exist-on-type-navigator
|
// See https://stackoverflow.com/questions/71538643/property-wakelock-does-not-exist-on-type-navigator
|
||||||
const requestWakeLock = async () => {
|
const requestWakeLock = async () => {
|
||||||
|
@ -53,13 +55,6 @@ const getLanguage = () => {
|
||||||
|
|
||||||
const i18nDict = createI18nContext(dict, getLanguage());
|
const i18nDict = createI18nContext(dict, getLanguage());
|
||||||
|
|
||||||
// const [watchDbStatus] = createWorkerSignal({
|
|
||||||
// provider: 'watchDb',
|
|
||||||
// });
|
|
||||||
// createEffect(() => {
|
|
||||||
// console.log({ caller: 'createEffect', watchDbStatus: watchDbStatus() });
|
|
||||||
// });
|
|
||||||
|
|
||||||
render(
|
render(
|
||||||
() => (
|
() => (
|
||||||
<Router>
|
<Router>
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
||||||
import maybePlusCode from './check-pluscodes';
|
|
||||||
|
|
||||||
describe('The maybePlusCode method', () => {
|
|
||||||
it('detects a valid short pluscode without qualifier', () => {
|
|
||||||
const code = '9G8F+6W';
|
|
||||||
expect(maybePlusCode(code)).toEqual({ code, isShort: true });
|
|
||||||
});
|
|
||||||
it('detects a valid short pluscode with qualifier', () => {
|
|
||||||
const code = '948G+V4 Oviedo';
|
|
||||||
expect(maybePlusCode(code)).toEqual({
|
|
||||||
code: '948G+V4',
|
|
||||||
qualifier: 'Oviedo',
|
|
||||||
isShort: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it('detects a valid long pluscode with 10 digits', () => {
|
|
||||||
const code = '9FFW84J9+XG';
|
|
||||||
expect(maybePlusCode(code)).toEqual({
|
|
||||||
code,
|
|
||||||
isShort: false,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it('detects a valid long pluscode with 8 digits', () => {
|
|
||||||
const code = '9FFW84J9+';
|
|
||||||
expect(maybePlusCode(code)).toEqual({
|
|
||||||
code,
|
|
||||||
isShort: false,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it('detects a valid long pluscode with 4 digits', () => {
|
|
||||||
const code = '9FFW0000+';
|
|
||||||
expect(maybePlusCode(code)).toEqual({
|
|
||||||
code,
|
|
||||||
isShort: false,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,16 +0,0 @@
|
||||||
const maybePlusRegexp =
|
|
||||||
/^([23456789CFGHJMPQRVWX]+0*\+[23456789CFGHJMPQRVWX]*)(\s+(.*))?$/;
|
|
||||||
|
|
||||||
const maybePlusCode = (code: string) => {
|
|
||||||
const matches = code.match(maybePlusRegexp);
|
|
||||||
if (!matches) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
code: matches[1],
|
|
||||||
isShort: matches[1].length < 9,
|
|
||||||
qualifier: matches[3] || undefined,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export default maybePlusCode;
|
|
|
@ -130,13 +130,4 @@ export const route = (route, coding = {}) => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getParentId = (id) => {
|
|
||||||
const tokens = id.split('/').slice(0, -1);
|
|
||||||
if (['1wpt', '2rte', '3trk'].includes(tokens.at(-1))) {
|
|
||||||
tokens.splice(-1);
|
|
||||||
}
|
|
||||||
const parentId = tokens.join('/');
|
|
||||||
return parentId;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default route;
|
export default route;
|
||||||
|
|