idk but it works
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "src/survex"]
|
||||
path = src/survex
|
||||
url = git@github.com:ojwb/survex.git
|
||||
BIN
Skydusky.3d
Normal file
BIN
Skydusky.3d
Normal file
Binary file not shown.
@@ -10,7 +10,7 @@ build () {
|
||||
|
||||
gofmt -w .
|
||||
staticcheck .
|
||||
CGO_ENABLED=1 GOARCH=amd64 go build -o ./cavepedia_linux_amd64 -v .
|
||||
CGO_ENABLED=1 GOARCH=amd64 go build -o ./kavea_linux_amd64 -v .
|
||||
|
||||
popd &>/dev/null
|
||||
}
|
||||
|
||||
BIN
src/Skydusky.3d
Normal file
BIN
src/Skydusky.3d
Normal file
Binary file not shown.
22
src/common.go
Normal file
22
src/common.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func checkError(err error) bool {
|
||||
if err != nil {
|
||||
log.Print("ERROR! " + err.Error())
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func checkWebError(w http.ResponseWriter, err error) bool {
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -2,4 +2,10 @@ module git.seaturtle.pw/pew/kavea
|
||||
|
||||
go 1.16
|
||||
|
||||
require github.com/zserge/lorca v0.1.10
|
||||
require (
|
||||
github.com/google/renameio v0.1.0 // indirect
|
||||
github.com/kisielk/gotool v1.0.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.3.0 // indirect
|
||||
github.com/zserge/lorca v0.1.10
|
||||
honnef.co/go/tools v0.2.1 // indirect
|
||||
)
|
||||
|
||||
45
src/go.sum
Normal file
45
src/go.sum
Normal file
@@ -0,0 +1,45 @@
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/zserge/lorca v0.1.10 h1:f/xBJ3D3ipcVRCcvN8XqZnpoKcOXV8I4vwqlFyw7ruc=
|
||||
github.com/zserge/lorca v0.1.10/go.mod h1:bVmnIbIRlOcoV285KIRSe4bUABKi7R7384Ycuum6e4A=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k=
|
||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
honnef.co/go/tools v0.2.1 h1:/EPr//+UMMXwMTkXvCCoaJDq8cpjMO80Ou+L4PDo2mY=
|
||||
honnef.co/go/tools v0.2.1/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY=
|
||||
22
src/img.go
Normal file
22
src/img.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -lm
|
||||
#include "img.h"
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"fmt"
|
||||
// "unsafe"
|
||||
)
|
||||
|
||||
func Test() {
|
||||
filename := C.CString("Skydusky.3d")
|
||||
pimg := C.img_open_survey(filename, nil)
|
||||
// for C.img_read_item(((*C.CStruct)(unsafe.Pointer(pimg))), ((*C.CStruct)(unsafe.Pointer((&pimg.mv))))) != C.img_BAD {
|
||||
for C.img_read_item(pimg, &pimg.mv) != C.img_BAD {
|
||||
if pimg.label != nil {
|
||||
fmt.Println(C.GoString(pimg.label))
|
||||
}
|
||||
}
|
||||
}
|
||||
413
src/img.h
Normal file
413
src/img.h
Normal file
@@ -0,0 +1,413 @@
|
||||
/* img.h
|
||||
* Header file for routines to read and write processed survey data files
|
||||
*
|
||||
* These routines support reading processed survey data in a variety of formats
|
||||
* - currently:
|
||||
*
|
||||
* - Survex ".3d" image files
|
||||
* - Survex ".pos" files
|
||||
* - Compass Plot files (".plt" and ".plf")
|
||||
* - CMAP XYZ files (".sht", ".adj", ".una", ".xyz")
|
||||
*
|
||||
* Writing Survex ".3d" image files is supported.
|
||||
*
|
||||
* Copyright (C) Olly Betts 1993,1994,1997,2001,2002,2003,2004,2005,2006,2010,2011,2012,2013,2014,2016,2018
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IMG_H
|
||||
# define IMG_H
|
||||
|
||||
/* Define IMG_API_VERSION if you want more recent versions of the img API.
|
||||
*
|
||||
* 0 (default) The old API. date1 and date2 give the survey date as time_t.
|
||||
* Set to 0 for "unknown".
|
||||
* 1 days1 and days2 give survey dates as days since 1st Jan 1900.
|
||||
* Set to -1 for "unknown".
|
||||
*/
|
||||
#ifndef IMG_API_VERSION
|
||||
# define IMG_API_VERSION 0
|
||||
#elif IMG_API_VERSION > 1
|
||||
# error IMG_API_VERSION > 1 too new
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h> /* for time_t */
|
||||
|
||||
# define img_BAD -2
|
||||
# define img_STOP -1
|
||||
# define img_MOVE 0
|
||||
# define img_LINE 1
|
||||
/* NB: img_CROSS is never output and ignored on input.
|
||||
* Put crosses where labels are. */
|
||||
/* # define img_CROSS 2 */
|
||||
# define img_LABEL 3
|
||||
# define img_XSECT 4
|
||||
# define img_XSECT_END 5
|
||||
/* Loop closure information for the *preceding* traverse (img_MOVE + one or
|
||||
* more img_LINEs). */
|
||||
# define img_ERROR_INFO 6
|
||||
|
||||
/* Leg flags */
|
||||
# define img_FLAG_SURFACE 0x01
|
||||
# define img_FLAG_DUPLICATE 0x02
|
||||
# define img_FLAG_SPLAY 0x04
|
||||
|
||||
/* Station flags */
|
||||
# define img_SFLAG_SURFACE 0x01
|
||||
# define img_SFLAG_UNDERGROUND 0x02
|
||||
# define img_SFLAG_ENTRANCE 0x04
|
||||
# define img_SFLAG_EXPORTED 0x08
|
||||
# define img_SFLAG_FIXED 0x10
|
||||
# define img_SFLAG_ANON 0x20
|
||||
# define img_SFLAG_WALL 0x40
|
||||
|
||||
/* File-wide flags */
|
||||
# define img_FFLAG_EXTENDED 0x80
|
||||
|
||||
/* When writing img_XSECT, img_XFLAG_END in pimg->flags means this is the last
|
||||
* img_XSECT in this tube:
|
||||
*/
|
||||
# define img_XFLAG_END 0x01
|
||||
|
||||
# define img_STYLE_UNKNOWN -1
|
||||
# define img_STYLE_NORMAL 0
|
||||
# define img_STYLE_DIVING 1
|
||||
# define img_STYLE_CARTESIAN 2
|
||||
# define img_STYLE_CYLPOLAR 3
|
||||
# define img_STYLE_NOSURVEY 4
|
||||
|
||||
/* 3D coordinates (in metres) */
|
||||
typedef struct {
|
||||
double x, y, z;
|
||||
} img_point;
|
||||
|
||||
typedef struct {
|
||||
/* Members you can access when reading (don't touch when writing): */
|
||||
char *label;
|
||||
int flags;
|
||||
char *title;
|
||||
/* If the coordinate system was specified, this contains a PROJ4 string
|
||||
* describing it. If not, this member will be NULL.
|
||||
*/
|
||||
char *cs;
|
||||
/* Older .3d format versions stored a human readable datestamp string.
|
||||
* Format versions >= 8 versions store a string consisting of "@" followed
|
||||
* by the number of seconds since midnight UTC on 1/1/1970. Some foreign
|
||||
* formats contain a human readable string, others no date information
|
||||
* (which results in "?" being returned).
|
||||
*/
|
||||
char *datestamp;
|
||||
/* The datestamp as a time_t (or (time_t)-1 if not available).
|
||||
*
|
||||
* For 3d format versions >= 8, this is a reliable value and in UTC. Older
|
||||
* 3d format versions store a human readable time, which img will attempt
|
||||
* to decode, but it may fail, particularly with handling timezones. Even
|
||||
* if it does work, beware that times in local time where DST applies are
|
||||
* inherently ambiguous around when the clocks go back.
|
||||
*
|
||||
* CMAP XYZ files contain a timestamp. It's probably in localtime (but
|
||||
* without any timezone information) and the example files are all pre-2000
|
||||
* and have two digit years. We do our best to turn these into a useful
|
||||
* time_t value.
|
||||
*/
|
||||
time_t datestamp_numeric;
|
||||
char separator; /* character used to separate survey levels ('.' usually) */
|
||||
|
||||
/* Members that can be set when writing: */
|
||||
#if IMG_API_VERSION == 0
|
||||
time_t date1, date2;
|
||||
#else /* IMG_API_VERSION == 1 */
|
||||
int days1, days2;
|
||||
#endif
|
||||
double l, r, u, d;
|
||||
|
||||
/* Error information - valid when img_ERROR_INFO is returned: */
|
||||
int n_legs;
|
||||
double length;
|
||||
double E, H, V;
|
||||
|
||||
/* The filename actually opened (e.g. may have ".3d" added).
|
||||
*
|
||||
* This is only set if img opened the filename - if an existing stream
|
||||
* is used (via img_read_stream() or similar) then this member will be
|
||||
* NULL.
|
||||
*/
|
||||
char * filename_opened;
|
||||
|
||||
/* Non-zero if reading an extended elevation: */
|
||||
int is_extended_elevation;
|
||||
|
||||
/* Members that can be set when writing: */
|
||||
/* The style of the data - one of the img_STYLE_* constants above */
|
||||
int style;
|
||||
|
||||
/* All other members are for internal use only: */
|
||||
FILE *fh; /* file handle of image file */
|
||||
int (*close_func)(FILE*);
|
||||
char *label_buf;
|
||||
size_t buf_len;
|
||||
size_t label_len;
|
||||
int fRead; /* 1 for reading, 0 for writing */
|
||||
long start;
|
||||
/* version of file format:
|
||||
* -4 => CMAP .xyz file, shot format
|
||||
* -3 => CMAP .xyz file, station format
|
||||
* -2 => Compass .plt file
|
||||
* -1 => .pos file
|
||||
* 0 => 0.01 ascii
|
||||
* 1 => 0.01 binary,
|
||||
* 2 => byte actions and flags
|
||||
* 3 => prefixes for legs; compressed prefixes
|
||||
* 4 => survey date
|
||||
* 5 => LRUD info
|
||||
* 6 => error info
|
||||
* 7 => more compact dates with wider range
|
||||
* 8 => lots of changes
|
||||
*/
|
||||
int version;
|
||||
char *survey;
|
||||
size_t survey_len;
|
||||
int pending; /* for old style text format files and survey filtering */
|
||||
img_point mv;
|
||||
#if IMG_API_VERSION == 0
|
||||
time_t olddate1, olddate2;
|
||||
#else /* IMG_API_VERSION == 1 */
|
||||
int olddays1, olddays2;
|
||||
#endif
|
||||
int oldstyle;
|
||||
} img;
|
||||
|
||||
/* Which version of the file format to output (defaults to newest) */
|
||||
extern unsigned int img_output_version;
|
||||
|
||||
/* Minimum supported value for img_output_version: */
|
||||
#define IMG_VERSION_MIN 1
|
||||
|
||||
/* Maximum supported value for img_output_version: */
|
||||
#define IMG_VERSION_MAX 8
|
||||
|
||||
/* Open a processed survey data file for reading
|
||||
*
|
||||
* fnm is the filename
|
||||
*
|
||||
* Returns pointer to an img struct or NULL
|
||||
*/
|
||||
#define img_open(F) img_open_survey((F), NULL)
|
||||
|
||||
/* Open a processed survey data file for reading
|
||||
*
|
||||
* fnm is the filename
|
||||
*
|
||||
* survey points to a survey name to restrict reading to (or NULL for all
|
||||
* survey data in the file)
|
||||
*
|
||||
* Returns pointer to an img struct or NULL
|
||||
*/
|
||||
img *img_open_survey(const char *fnm, const char *survey);
|
||||
|
||||
/* Read processed survey data from an existing stream.
|
||||
*
|
||||
* stream is a FILE* open on the stream (can be NULL which will give error
|
||||
* IMG_FILENOTFOUND so you don't need to handle that case specially). The
|
||||
* stream should be opened for reading in binary mode and positioned at the
|
||||
* start of the survey data file.
|
||||
*
|
||||
* close_func is a function to call to close the stream (most commonly
|
||||
* fclose, or pclose if the stream was opened using popen()) or NULL if
|
||||
* the caller wants to take care of closing the stream.
|
||||
*
|
||||
* filename is used to determine the format based on the file extension,
|
||||
* and also the leafname with the extension removed is used for the survey
|
||||
* title for formats which don't support a title or when no title is
|
||||
* specified. If you're not interested in default titles, you can just
|
||||
* pass the extension including a leading "." - e.g. ".3d". May not be
|
||||
* NULL.
|
||||
*
|
||||
* Returns pointer to an img struct or NULL on error. Any close function
|
||||
* specified is called on error (unless stream is NULL).
|
||||
*/
|
||||
#define img_read_stream(S, C, F) img_read_stream_survey((S), (C), (F), NULL)
|
||||
|
||||
/* Read processed survey data from an existing stream.
|
||||
*
|
||||
* stream is a FILE* open on the stream (can be NULL which will give error
|
||||
* IMG_FILENOTFOUND so you don't need to handle that case specially). The
|
||||
* stream should be opened for reading in binary mode and positioned at the
|
||||
* start of the survey data file.
|
||||
*
|
||||
* close_func is a function to call to close the stream (most commonly
|
||||
* fclose, or pclose if the stream was opened using popen()) or NULL if
|
||||
* the caller wants to take care of closing the stream.
|
||||
*
|
||||
* filename is used to determine the format based on the file extension,
|
||||
* and also the leafname with the extension removed is used for the survey
|
||||
* title for formats which don't support a title or when no title is
|
||||
* specified. If you're not interested in default titles, you can just
|
||||
* pass the extension including a leading "." - e.g. ".3d". filename must
|
||||
* not be NULL.
|
||||
*
|
||||
* survey points to a survey name to restrict reading to (or NULL for all
|
||||
* survey data in the file)
|
||||
*
|
||||
* Returns pointer to an img struct or NULL on error. Any close function
|
||||
* specified is called on error.
|
||||
*/
|
||||
img *img_read_stream_survey(FILE *stream, int (*close_func)(FILE*),
|
||||
const char *filename,
|
||||
const char *survey);
|
||||
|
||||
/* Open a .3d file for output with no specified coordinate system
|
||||
*
|
||||
* This is a very thin wrapper around img_open_write_cs() which passes NULL for
|
||||
* cs, provided for compatibility with the API provided before support for
|
||||
* coordinate systems was added.
|
||||
*
|
||||
* See img_open_write_cs() for documentation.
|
||||
*/
|
||||
#define img_open_write(F, T, S) img_open_write_cs(F, T, NULL, S)
|
||||
|
||||
/* Open a .3d file for output in a specified coordinate system
|
||||
*
|
||||
* fnm is the filename
|
||||
*
|
||||
* title is the title
|
||||
*
|
||||
* cs is a PROJ4 string describing the coordinate system (or NULL to not
|
||||
* specify a coordinate system).
|
||||
*
|
||||
* flags contains a bitwise-or of any file-wide flags - currently only one
|
||||
* is available: img_FFLAG_EXTENDED.
|
||||
*
|
||||
* Returns pointer to an img struct or NULL for error (check img_error()
|
||||
* for details)
|
||||
*/
|
||||
img *img_open_write_cs(const char *fnm, const char *title, const char * cs,
|
||||
int flags);
|
||||
|
||||
/* Write a .3d file to a stream
|
||||
*
|
||||
* stream is a FILE* open on the stream (can be NULL which will give error
|
||||
* IMG_FILENOTFOUND so you don't need to handle that case specially). The
|
||||
* stream should be opened for writing in binary mode.
|
||||
*
|
||||
* close_func is a function to call to close the stream (most commonly
|
||||
* fclose, or pclose if the stream was opened using popen()) or NULL if
|
||||
* the caller wants to take care of closing the stream.
|
||||
*
|
||||
* title is the title
|
||||
*
|
||||
* cs is a PROJ4 string describing the coordinate system (or NULL to not
|
||||
* specify a coordinate system).
|
||||
*
|
||||
* flags contains a bitwise-or of any file-wide flags - currently only one
|
||||
* is available: img_FFLAG_EXTENDED.
|
||||
*
|
||||
* Returns pointer to an img struct or NULL for error (check img_error()
|
||||
* for details). Any close function specified is called on error (unless
|
||||
* stream is NULL).
|
||||
*/
|
||||
img *img_write_stream(FILE *stream, int (*close_func)(FILE*),
|
||||
const char *title, const char * cs, int flags);
|
||||
|
||||
/* Read an item from a processed survey data file
|
||||
*
|
||||
* pimg is a pointer to an img struct returned by img_open()
|
||||
*
|
||||
* coordinates are returned in p
|
||||
*
|
||||
* flags and label name are returned in fields in pimg
|
||||
*
|
||||
* Returns img_XXXX as #define-d above
|
||||
*/
|
||||
int img_read_item(img *pimg, img_point *p);
|
||||
|
||||
/* Write a item to a .3d file
|
||||
*
|
||||
* pimg is a pointer to an img struct returned by img_open_write()
|
||||
*
|
||||
* code is one of the img_XXXX #define-d above
|
||||
*
|
||||
* flags is the leg, station, or xsect flags
|
||||
* (meaningful for img_LINE, img_LABEL, and img_XSECT respectively)
|
||||
*
|
||||
* s is the label (only meaningful for img_LABEL)
|
||||
*
|
||||
* x, y, z are the coordinates
|
||||
*/
|
||||
void img_write_item(img *pimg, int code, int flags, const char *s,
|
||||
double x, double y, double z);
|
||||
|
||||
/* Write error information for the current traverse
|
||||
*
|
||||
* n_legs is the number of legs in the traverse
|
||||
*
|
||||
* length is the traverse length (in m)
|
||||
*
|
||||
* E is the ratio of the observed misclosure to the theoretical one
|
||||
*
|
||||
* H is the ratio of the observed horizontal misclosure to the theoretical one
|
||||
*
|
||||
* V is the ratio of the observed vertical misclosure to the theoretical one
|
||||
*/
|
||||
void img_write_errors(img *pimg, int n_legs, double length,
|
||||
double E, double H, double V);
|
||||
|
||||
/* rewind a processed survey data file opened for reading
|
||||
*
|
||||
* This is useful if you want to read the data in several passes.
|
||||
*
|
||||
* pimg is a pointer to an img struct returned by img_open()
|
||||
*
|
||||
* Returns: non-zero for success, zero for error (check img_error() for
|
||||
* details)
|
||||
*/
|
||||
int img_rewind(img *pimg);
|
||||
|
||||
/* Close a processed survey data file
|
||||
*
|
||||
* pimg is a pointer to an img struct returned by img_open() or
|
||||
* img_open_write()
|
||||
*
|
||||
* Returns: non-zero for success, zero for error (check img_error() for
|
||||
* details)
|
||||
*/
|
||||
int img_close(img *pimg);
|
||||
|
||||
/* Codes returned by img_error */
|
||||
typedef enum {
|
||||
IMG_NONE = 0, IMG_FILENOTFOUND, IMG_OUTOFMEMORY,
|
||||
IMG_CANTOPENOUT, IMG_BADFORMAT, IMG_DIRECTORY,
|
||||
IMG_READERROR, IMG_WRITEERROR, IMG_TOONEW
|
||||
} img_errcode;
|
||||
|
||||
/* Read the error code
|
||||
*
|
||||
* If img_open(), img_open_survey() or img_open_write() returns NULL, or
|
||||
* img_rewind() or img_close() returns 0, or img_read_item() returns img_BAD
|
||||
* then you can call this function to discover why.
|
||||
*/
|
||||
img_errcode img_error(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
BIN
src/kavea_linux_amd64
Executable file
BIN
src/kavea_linux_amd64
Executable file
Binary file not shown.
@@ -1,19 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"log"
|
||||
"net/http"
|
||||
"runtime"
|
||||
|
||||
"github.com/blevesearch/bleve/v2"
|
||||
"github.com/zserge/lorca"
|
||||
)
|
||||
|
||||
//go:embed templates
|
||||
var templatesHTML embed.FS
|
||||
|
||||
//go:embed static
|
||||
var staticFiles embed.FS
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.Lshortfile)
|
||||
Test()
|
||||
|
||||
/* Web Server */
|
||||
http.Handle("/static/", http.FileServer(http.FS(staticFiles)))
|
||||
|
||||
16
src/static/babylon-4.2.0.gui.min.js
vendored
Normal file
16
src/static/babylon-4.2.0.gui.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
16
src/static/babylon-4.2.0.js
Normal file
16
src/static/babylon-4.2.0.js
Normal file
File diff suppressed because one or more lines are too long
16
src/static/babylonjs-4.2.0.loaders.min.js
vendored
Normal file
16
src/static/babylonjs-4.2.0.loaders.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
13
src/static/kavea.css
Normal file
13
src/static/kavea.css
Normal file
@@ -0,0 +1,13 @@
|
||||
html, body {
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#renderCanvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
touch-action: none;
|
||||
}
|
||||
1
src/survex
Submodule
1
src/survex
Submodule
Submodule src/survex added at 738af383b5
44
src/templates/index.html.tmpl
Normal file
44
src/templates/index.html.tmpl
Normal file
@@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>kavea</title>
|
||||
<link rel="stylesheet" href="/static/kavea.css">
|
||||
<script src="/static/babylon-4.2.0.js"></script>
|
||||
<script src="/static/babylonjs-4.2.0.loaders.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="renderCanvas"></canvas>
|
||||
|
||||
<script>
|
||||
const canvas = document.getElementById("renderCanvas"); // Get the canvas element
|
||||
const engine = new BABYLON.Engine(canvas, true); // Generate the BABYLON 3D engine
|
||||
|
||||
// Add your code here matching the playground format
|
||||
const createScene = function () {
|
||||
|
||||
const scene = new BABYLON.Scene(engine);
|
||||
|
||||
BABYLON.SceneLoader.ImportMeshAsync("", "https://assets.babylonjs.com/meshes/", "box.babylon");
|
||||
|
||||
const camera = new BABYLON.ArcRotateCamera("camera", -Math.PI / 2, Math.PI / 2.5, 15, new BABYLON.Vector3(0, 0, 0));
|
||||
camera.attachControl(canvas, true);
|
||||
const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(1, 1, 0));
|
||||
|
||||
return scene;
|
||||
};
|
||||
|
||||
|
||||
const scene = createScene(); //Call the createScene function
|
||||
|
||||
// Register a render loop to repeatedly render the scene
|
||||
engine.runRenderLoop(function () {
|
||||
scene.render();
|
||||
});
|
||||
|
||||
// Watch for browser/canvas resize events
|
||||
window.addEventListener("resize", function () {
|
||||
engine.resize();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
16
src/web.go
Normal file
16
src/web.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetHome(w http.ResponseWriter, r *http.Request) {
|
||||
t, err := template.ParseFS(templatesHTML, "templates/index.html.tmpl")
|
||||
if !checkWebError(w, err) {
|
||||
return
|
||||
}
|
||||
|
||||
err = t.Execute(w, nil)
|
||||
checkError(err)
|
||||
}
|
||||
Reference in New Issue
Block a user