|
Post by alexfish on Sept 29, 2022 16:48:29 GMT 1
Hi Joe have not tested , looks like can create read file HEREBR Alex
|
|
|
Post by alexfish on Sept 29, 2022 19:52:52 GMT 1
Hi Joe image2seamaphave done qml map image2seamap image Self test done and it does work only one image is added so no increase in data beyond the one that depends on the bacon append working ? For Areas Covered by openseamaps look HEREthis method can get likes of USA and Mexico sea picky and more HOME$ = GETENVIRON$("HOME") ' may have to change this depends on QtLocation Version SEARCHDIR$ = HOME$ & "/.cache/QtLocation/5.8/tiles/osm/" PRINT SEARCHDIR$ datafile$ = SEARCHDIR$ & "data.txt" ' File seamap_converter.bac qml maps images OPTION PARSE FALSE '=========================================== PRAGMA LDFLAGS `pkg-config --libs gdk-pixbuf-2.0` PRAGMA OPTIONS `pkg-config --cflags gdk-pixbuf-2.0` '=========================================== PRAGMA INCLUDE <gdk-pixbuf-2.0/gdk-pixbuf/gdk-pixbuf.h> SUB COMPOSIT_IMAGE(SOURCER$ , DESTINATION$)
LOCAL im1 , im2 TYPE GdkPixbuf* im1 = gdk_pixbuf_new_from_file(DESTINATION$ , NULL) im2 = gdk_pixbuf_new_from_file(SOURCER$, NULL)
w = gdk_pixbuf_get_width(im2) h = gdk_pixbuf_get_height(im2) IF w = -1 THEN
ELSE gdk_pixbuf_composite(im2, im1, 0, 0, w, h, 0,0, 1,1, 0,255) gdk_pixbuf_save (im1,DESTINATION$, "png", 0, NULL, NULL, NULL)
END IF g_object_unref(im1) g_object_unref(im2) END SUB
SUB UPDATE(int rebuild)
myfile$ = WALK$(SEARCHDIR$, 1, ".+", TRUE, NL$)
data$ = "lost" IF ( FILEEXISTS(datafile$) AND (rebuild) ) THEN DELETE FILE datafile$ END IF OPEN datafile$ FOR APPENDING AS myfile IF FILELEN(datafile$) THEN data$ = LOAD$(datafile$) END IF
FOR item$ IN myfile$ STEP NL$ IF INSTR(item$,".png") THEN F1$= REPLACE$(MID$(MID$(item$,INSTR(item$,"-")),6),"-","/")
TILE$ ="http://t1.openseamap.org/seamark/" & F1$
IF INSTR(data$,TILE$) THEN PRINT "NoCON" ELSE Cmd$ = "wget " & TILE$ & " -O " & SEARCHDIR$ & "source.png" SYSTEM(Cmd$) WRITELN TILE$ TO myfile
scr$ =SEARCHDIR$ & "source.png"
IF FILEEXISTS(scr$) THEN PRINT TILE$ PRINT scr$ PRINT item$ COMPOSIT_IMAGE(scr$,item$) DELETE FILE scr$ PRINT "=========================================" END IF END IF END IF
NEXT CLOSE FILE myfile PRINT " DONE"
END SUB
'0 just update 1 rebuild UPDATE(0)
BR Alex Attachments:
|
|
|
Post by bigbass on Oct 1, 2022 20:03:53 GMT 1
Thanks Alex
for the way to update the maps to use image2seamap and all you code snippets and links
*maybe a one image screen shot before and after to show the changes to see the expected result?
Joe
|
|
|
Post by bigbass on Oct 2, 2022 3:31:00 GMT 1
Hello Alex and all well here is a command line way to enter an address and get a gps lat lon location expected result ------------------- Qt Version: 5.15.2 Try service: OSM Searching... Reply: location returned. Lat.: 28.2897 Long.: -81.4067 ----------------- may come in handy after more testing I spent a lot of time reducing this down and porting it to linux and bacon almost gave up a few times on this one wasn't easy but I wanted to get a demo for it take a look at the callback QObject::connect in the original code spans many lines without a real callback! in c++ they use signal and slots the slot was 30 lines of code instead of using a function or sub stackoverflow.com/questions/43259557/how-to-get-latitude-longitude-from-one-geo-address-using-qt-c-on-windows
' Qt header: PRAGMA INCLUDE <QCoreApplication> <QGeoAddress> <QGeoCodingManager> PRAGMA INCLUDE <QGeoCoordinate> <QGeoLocation> <QGeoServiceProvider> PRAGMA INCLUDE <QtCore> <QDebug> PRAGMA LDFLAGS -lQt5Location -lQt5PositioningQuick PRAGMA LDFLAGS -lQt5Quick -lQt5Gui -lQt5Positioning -lQt5QmlModels PRAGMA LDFLAGS -lQt5Qml -lQt5Network -lQt5Core PRAGMA LDFLAGS -lpthread -latomic
PRAGMA COMPILER g++ PRAGMA OPTIONS -fPIC -Wno-write-strings -Wno-pointer-arith -lpthread -latomic
'RPI3 and 4 PRAGMA OPTIONS -I. PRAGMA OPTIONS -I/usr/lib/arm-linux-gnueabihf PRAGMA OPTIONS -I/usr/include/arm-linux-gnueabihf/qt5 PRAGMA OPTIONS -I/usr/include/arm-linux-gnueabihf/qt5/QtCore PRAGMA OPTIONS -I/usr/include/arm-linux-gnueabihf/qt5/QtGui PRAGMA OPTIONS -I/usr/include/arm-linux-gnueabihf/qt5/QtQml PRAGMA OPTIONS -I/usr/include/arm-linux-gnueabihf/qt5/QtQmlModels PRAGMA OPTIONS -I/usr/include/arm-linux-gnueabihf/qt5/QtQuick PRAGMA OPTIONS -I/usr/lib/arm-linux-gnueabihf/metatypes PRAGMA OPTIONS -I/usr/include/arm-linux-gnueabihf/qt5/QtLocation PRAGMA OPTIONS -I/usr/include/arm-linux-gnueabihf/qt5/QtPositioning PRAGMA OPTIONS -I/usr/include/arm-linux-gnueabihf/qt5/QtWidgets
OPTION PARSE FALSE
DEF FN PRINTOUT(x) = qDebug() << (x)
'-------------------------- SUB ptrQGeoCode_cb '-------------------------- LOCAL qGeoLocs TYPE QList<QGeoLocation> PRINT "Reply: " ' eval. result qGeoLocs = ptrQGeoCode->locations() PRINT "location returned." for (QGeoLocation &qGeoLoc : qGeoLocs) { qGeoLoc.setAddress(addr) QGeoCoordinate qGeoCoord = qGeoLoc.coordinate() PRINT "Lat.: " PRINTOUT( qGeoCoord.latitude()) PRINT "Long.: " PRINTOUT(qGeoCoord.longitude()) } END ENDSUB
PRINT "Qt Version: " PRINTOUT( QT_VERSION_STR)
DECLARE app TYPE QCoreApplication* DECLARE ptrQGeoCode TYPE QGeoCodeReply* DECLARE addr TYPE QGeoAddress DECLARE ptrQGeoCoder TYPE QGeoCodingManager*
' main application app = new QCoreApplication(argc, argv) PRINT "Try service: OSM" ' force provider osm QGeoServiceProvider qGeoService("osm") QGeoCodingManager *ptrQGeoCoder = qGeoService.geocodingManager() IF NOT (ptrQGeoCoder) THEN PRINT "GeoCodingManager OSM" PRINT " not available!" END IF 'more options 'addr.setState(QString::fromUtf8("state")) 'addr.setStreet(QString::fromUtf8("road")) 'addr.setDistrict(QString::fromUtf8("suburb")) 'use like html %20 is a space found out experimenting addr.setCountry(QString::fromUtf8("United_States")) addr.setPostalCode(QString::fromUtf8("44741")) addr.setState(QString::fromUtf8("Florida")) addr.setCity(QString::fromUtf8("Kissimmee")) '-- st.number street drive addr.setStreet(QString::fromUtf8("69%20Lakeview%20Dr")) ptrQGeoCode = ptrQGeoCoder->geocode(addr) IF NOT (ptrQGeoCode) THEN EPRINT "GeoCoding failed!" END IF PRINT "Searching..." ' widget ------SIGNAL------------ callback QObject::connect(ptrQGeoCode, &QGeoCodeReply::finished, ptrQGeoCode_cb) return app->exec()
|
|
|
Post by alexfish on Oct 2, 2022 11:41:44 GMT 1
Thanks Alex for the way to update the maps to use image2seamap and all you code snippets and links *maybe a one image screen shot before and after to show the changes to see the expected result? Joe Hi Joe I ran the code over the directory , so can not prove the before but can see from the picky which tile has been changed Have tested the above code , all OK BR Alex Attachments:
|
|
|
Post by alexfish on Oct 2, 2022 16:33:54 GMT 1
Hi All OK got this convert demo have updated main.qml to qml3 :: added button , could be enhanced how ever this allows not to track the gps signal : so can wonder where ever here I get whitby uk in view; then do an update with the converter See Code at above image2seamapBR Alex pickys +updated main3.qml Attachments:
main3.qml.bz2 (1.83 KB)
|
|
|
Post by alexfish on Oct 2, 2022 22:25:13 GMT 1
Hi Joe Found a problem while testing:: default tile cache size one will need to set this Else will need to re-run the convert to seamap looks like this is a go by road & have internet connection etc etc: good job have internet with legs bit of a data eater if not got unlimited data: If set the can put the while loop on to redo from start delete the data.txt Read HERE sort of reminds me of a seamap app I have on android pad. also can restrict the zoom levels IE Map { id:mapview anchors.fill: parent plugin: osmPlugin minimumZoomLevel : 13 maximumZoomLevel: 17 center: QtPositioning.coordinate(0,0) zoomLevel: 14 ADDED main3.qml Updated:: whats the difference: check it out BR Alex Attachments:main3.qml.bz2 (1.96 KB)
|
|
|
Post by alexfish on Oct 3, 2022 16:23:16 GMT 1
Hi Joe found some info Re gpds ; qml has an interface HEREbits of qml code : Map{ id: mapview anchors.fill: parent;plugin:osmPlugin;minimumZoomLevel:13;maximumZoomLevel: 17; center: QtPositioning.coordinate (0, 0) zoomLevel:14
PositionSource { id:mySocket nmeaSource: "socket://127.0.0.1:2947" onPositionChanged:console.log("CHANGED") } if set the location 0,0 socket seems to connect result ./dynamic-map qml: CHANGED
further reading possible interface for reading external sources BR Alex
|
|
|
Post by bigbass on Oct 3, 2022 19:06:52 GMT 1
Hello Alex the last main3.qml looking good!
as for this line
nmeaSource: "socket://127.0.0.1:2947"
that led me down the road of sockets on the c++ side of the code to connect to the qml side of the code and communicate
in short the way the code is working now we get around a complex setup of doing it the "official way" of creating sockets for Qt we do already have a socket reading the port using c++ on localhost but it is not taking to Qt yet
stay away from any code that is for nokia its a dead end in a long rabbit hole that if you did get it to work you would need an api key anyway
this is why I stuck with the osm code and did geolocations on a side note for all the good working demos you need to compile qtlocation from git It took me several tries to finally get that working and that solves all those "private" headers that are nowhere to be found you have to build it! that builds all the plugins for maps and the private headers needed
*I will at some point ( in a few days) start clean and document the steps for qtlocations but I was adding stuff error for error solving until it compiled and will pass it to a wiki page so that it can be repeated step by step this was for qt 5.15.2
the good news we will be making leaps and bounds with the new demos once ported over to bacon they solve all the complex connecting to the plugins !
Joe
|
|
|
Post by alexfish on Oct 4, 2022 21:20:16 GMT 1
Hi Joe
Not taking all of that in ,will try to digest...
in mean time thought would try `pkg-config`
Up to now got below header working on pi4 , so wonder if some one could test dynamic-map on other os
PRAGMA INCLUDE <string.h> <stdio.h> <libgpsmm.h> <math.h> <iostream> PRAGMA LDFLAGS -std=c++17 -Wall -pedantic -pthread -lgps PRAGMA INCLUDE <QGuiApplication> <QQmlApplicationEngine> PRAGMA INCLUDE <QtCore> <QDebug> <QtCore/QTimer>
PRAGMA LDFLAGS `pkg-config Qt5Location Qt5PositioningQuick Qt5Quick --libs` PRAGMA LDFLAGS `pkg-config Qt5Gui Qt5Positioning Qt5QmlModels --libs` PRAGMA LDFLAGS `pkg-config Qt5Qml Qt5Network Qt5Core --libs`
PRAGMA OPTIONS `pkg-config Qt5Location Qt5PositioningQuick Qt5Quick --cflags` PRAGMA OPTIONS `pkg-config Qt5Gui Qt5Positioning Qt5QmlModels --cflags` PRAGMA OPTIONS `pkg-config Qt5Qml Qt5Network Qt5Core --cflags`
PRAGMA LDFLAGS -lpthread -latomic PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -fPIC PRAGMA OPTIONS -Wno-deprecated
PRAGMA COMPILER g++ OPTION PARSE FALSE qputenv("QML_XHR_ALLOW_FILE_READ", QByteArray("1"))
DEF FN PRINTOUT(x) = qDebug() << (x)
DECLARE app TYPE QGuiApplication* DECLARE engine TYPE QQmlApplicationEngine*
also in mean time can have a bit of fun , understanding gps and how to identify which tile contains the position + standard osm format & qml format
DEF FN ASINH = asinh DEF FN ATAN = atan 'radius at equater DEF FN OSM_EQ_RADIUS = 6378137.0
' https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames ' source$ server [a,b,c]
' get the tile x FUNCTION LONG_TO_PIX(int ZOOM, double longditude) TYPE int LOCAL TILE_X TYPE int TILE_X = (int)(FLOOR(( longditude +180.0) /360 *(1 << ZOOM))) RETURN TILE_X END FUNCTION 'get the tile y ' ===================================================== FUNCTION LAT_TO_PIX(int ZOOM, double latitude) TYPE int
LOCAL TILE_Y TYPE int LOCAL LAT_RAD TYPE double
LAT_RAD = latitude * PI / 180
TILE_Y = (int)FLOOR( (1.0 - ASINH(TAN(LAT_RAD)) / PI) / 2.0 * (1 << ZOOM)) RETURN TILE_Y
END FUNCTION 'where are we in the tile ' ===================================================== FUNCTION TILE_X_TO_LONG(int x, int z) TYPE double
RETURN x / (double)(1 << z) * 360.0 - 180
END FUNCTION
' ===================================================== FUNCTION TILE_Y_TO_LAT(int y, int z) TYPE double
LOCAL n TYPE double n = PI - 2.0 * PI * y / (double)(1 << z) RETURN 180.0 / PI * ATAN(0.5 * (exp(n) - exp(-n)))
END FUNCTION
' ====================================================== LOCAL longditude = -0.1278 TYPE double LOCAL latitude = 51.5074 TYPE double LOCAL zoom = 14
TILE_X = LONG_TO_PIX(zoom,longditude) TILE_Y = LAT_TO_PIX(zoom,latitude) PRINT "Pos= lat : " , latitude, ":lon:" , longditude PRINT "standard osm format : "; PRINT "/", STR$(zoom),"/", STR$(TILE_X),"/",STR$(TILE_Y),".png" PRINT "qml osm format : "; PRINT "osm_100-l-1-",STR$(zoom),"-", STR$(TILE_X),"-",STR$(TILE_Y),".png" PRINT " your tile is here " LOCAL X_LON_1 TYPE double LOCAL Y_LAT_1 TYPE double X_LON_1 = TILE_X_TO_LONG(TILE_X,zoom) Y_LAT_1 = TILE_Y_TO_LAT(TILE_Y,zoom) PRINT " lat: " , Y_LAT_1 , ":lon:" , X_LON_1
If follow the link in code there is a ECMAScript (JavaScript/ActionScript, etc.) how to BR Alex
|
|
|
Post by bigbass on Oct 10, 2022 22:27:55 GMT 1
I did this with an App called Dall-e An AI from words I described Joe
|
|
|
Post by bigbass on Oct 17, 2022 1:19:33 GMT 1
Hello Alex all the examples that were attached in this thread I ported them to Manjarothe dependencies are different qt5-declarative qt5-location gpsd inetutils qt5-quickcontrols qt5-quickcontrols2
and even the script I used for the gps forwarding changed the hostname command doesnt work the same the ip is found doing ifconfig wlan0 | grep -i mask | awk '{print $2}'| cut -f2 they are all here in this folder sourceforge.net/projects/bacon-qt5/files/MANJARO/
|
|
|
Post by alexfish on Oct 19, 2022 9:57:05 GMT 1
Hi Joe & All
gpsd:
I have tested a wifi gpsais device with gpsd depending on the device check your docs/manual may need to stop the gpsd use root
systemctl stop gpsd systemctl stop gpsd.socket then tcp:conection example
gpsd tcp://192.168.1.100:2000 see if info available
gpspipe -r in this case :: no picky or output Joe do you connect phone through udp: BR Alex
|
|
|
Post by bigbass on Oct 19, 2022 14:57:04 GMT 1
Hello Alex "Joe do you connect phone through udp:" yes and tested on both debian and Manjaro to be working but there is a difference in the getting of the local ip due to the hostname command is not the same for Manjaro but it is an easy fix this script is named setup-gps for Manjaro #!/bin/bash #bash script by bigbass
sudo systemctl stop gpsd.socket sudo killall -9 gpsd
MYIP=$(ifconfig wlan0 | grep -i mask | awk '{print $2}'| cut -f2 )
printf "now start your gpsd android app with ip \e[44m ${MYIP}\e[0m \n" printf "android app port with \e[44m 1101\e[0m \n"
printf "I connected your raspberry pi using udp to \e[44m ${MYIP}:1101\e[0m \n" printf "open a new terminal and type \e[44m gpsmon\e[0m \n"
gpsd -N udp://${MYIP}":1101"
all the details are here just to be complete since it is spread over different posts connecting your android phone to wifi and sending you gps data to the raspberry pinote this link is using debian experimental-coding.freeforums.net/post/685this link is a demo we both used (you modified for debian) ported to manjaro I tested this to be working sourceforge.net/projects/bacon-qt5/files/MANJARO/dynamic2.tar.bz2/downloadhope something there could be useful the connecting part to gspd should work well with udp just change the port number P.S forgot to say ifconfig is not installed by default it is in the package net-tools sudo pacman -S net-tools BR Joe
|
|
|
Post by alexfish on Oct 19, 2022 16:31:01 GMT 1
Hi Joe
Thanks for the reply:
all info is useful , to me and others
at this side just touch down with first ais(mmsi)
bit of code
IF (gps_data.ais.mmsi) THEN CLEAR PRINT "\nAis mmsi: ",gps_data.ais.mmsi ,"\n"
END IF
not seem much but getting through all info from sub structs = daunting task , depend on this depends on that and if if that or blagh,blagh,blaght....
anyway: output, other info suppressed
Ais mmsi: 232030100
Fix mode: 3D Time: BR Alex
|
|