Änderungen am TAgebuch

This commit is contained in:
Torsten Schulz
2024-08-30 11:50:54 +02:00
parent 828035d339
commit 1ac1fc9ca0
116 changed files with 6859 additions and 6765 deletions

View File

@@ -4,4 +4,7 @@ DB_PASSWORD=hitomisan
DB_NAME=trainingsdiary
DB_DIALECT=mysql
JWT_SECRET=x9H7ggzio13P3DF
ENCRYPTION_KEY=x9H7ggzio13P3DF
ENCRYPTION_KEY=daa9cf7ef5b8c5021b455721fedaf10bc1739897c6d9c6d40e4fa3013c4ac83b
EMAIL_USER=tsschulz2001@gmail.com
EMAIL_PASS=wiuo rhxq vmxe eyaj
BASE_URL=http://localhost:3000

View File

@@ -3,9 +3,9 @@ import dotenv from 'dotenv';
dotenv.config();
export const development = {
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
username: process.env.DB_USER || 'root',
password: process.env.DB_PASSWORD || 'hitomisan',
database: process.env.DB_NAME || 'trainingdiary',
host: process.env.DB_HOST,
dialect: process.env.DB_DIALECT,
define: {
@@ -14,3 +14,4 @@ export const development = {
underscoredAll: true,
},
};

View File

@@ -1,52 +1,77 @@
import Club from '../models/Club.js';
import UserClub from '../models/UserClub.js';
import User from '../models/User.js';
import Member from '../models/Member.js';
import { Op, fn, where, col } from 'sequelize';
import { getUserByToken } from '../utils/userUtils.js';
const getClubs = async (req, res) => {
const clubs = await Club.findAll();
res.status(200).json(clubs);
try {
console.log('[getClubs] - get clubs');
const clubs = await Club.findAll();
console.log('[getClubs] - prepare response');
res.status(200).json(clubs);
console.log('[getClubs] - done');
} catch (error) {
console.log('[getClubs] - error');
console.log(error);
res.status(500).json({ error: "internalerror" });
}
};
const addClub = async (req, res) => {
console.log('[addClub] - Read out parameters');
const { authcode: token } = req.headers;
const { name: clubName } = req.body;
console.log('[addClub] - find club by name');
const club = await Club.findOne({
where: where(fn('LOWER', col('name')), 'LIKE', `%${clubName.toLowerCase()}%`)
});
console.log('[addClub] - get user');
const user = await getUserByToken(token);
console.log('[addClub] - check if club already exists');
if (club) {
res.status(409).json({ error: "alreadyexists" });
return;
}
const newClub = Club.create({ name: clubName });
console.log('[addClub] - create club');
const newClub = await Club.create({ name: clubName });
console.log('[addClub] - add user to new club');
UserClub.create({ userId: user.id, clubId: newClub.id, approved: true });
console.log('[addClub] - prepare response');
res.status(200).json(newClub);
console.log('[addClub] - done');
}
const getClub = async (req, res) => {
const { authcode: token } = req.headers;
const { clubid: clubId } = req.params;
console.log('load club', token)
const user = await getUserByToken(token);
console.log(user);
const access = await UserClub.findAll({
where: {
userId: user.id,
clubId: clubId,
}
});
if (access.length === 0 || !access[0].approved) {
res.status(403).json({ error: "noaccess", status: access.length === 0 ? "notrequested" : "requested" });
return;
}
console.log('[getClub] - start');
try {
const { authcode: token } = req.headers;
const { clubid: clubId } = req.params;
console.log('[getClub] - get user');
const user = await getUserByToken(token);
console.log('[getClub] - get users club');
const access = await UserClub.findAll({
where: {
userId: user.id,
clubId: clubId,
}
});
console.log('[getClub] - check access');
if (access.length === 0 || !access[0].approved) {
res.status(403).json({ error: "noaccess", status: access.length === 0 ? "notrequested" : "requested" });
return;
}
console.log('[getClub] - get club');
const club = await Club.findByPk(clubId, {
include: [
{
model: Member,
as: 'Members',
as: 'members',
order: [
['lastName', 'ASC'], // Sortiere nach Nachname aufsteigend
['firstName', 'ASC'] // Sortiere nach Vorname aufsteigend
],
},
{
model: User,
@@ -57,13 +82,15 @@ const getClub = async (req, res) => {
}
]
});
console.log('[getClub] - check club exists');
if (!club) {
return res.status(404).json({ message: 'Club not found' });
}
console.log('[getClub] - set response');
res.status(200).json(club);
console.log('[getClub] - done');
} catch (error) {
console.error('err', error);
console.log(error);
res.status(500).json({ message: 'Server error' });
}
}
@@ -106,7 +133,7 @@ const approveClubAccess = async (req, res) => {
res.status(200).json({ status: 'ok' });
}
const requestClubAccess = async(req, res) => {
const requestClubAccess = async (req, res) => {
const { authcode: token } = req.headers;
const { clubid: clubId } = req.params;
const user = await getUserByToken(token);
@@ -114,16 +141,18 @@ const requestClubAccess = async(req, res) => {
const access = await UserClub.findAll({
where: {
userId: user.id,
clubId: clubId,
clubId: clubId,
}
});
if (access.length > 0) {
res.status(409).json({ err: "alreadyrequested"});
res.status(409).json({ err: "alreadyrequested" });
return;
}
const club = Club.findOne({ where: {
id: clubId
}});
const club = Club.findOne({
where: {
id: clubId
}
});
if (!club) {
res.status(404).json({ err: "clubnotfound" });
return;

View File

@@ -0,0 +1,54 @@
import DiaryService from '../services/diaryService.js';
import HttpError from '../exceptions/HttpError.js';
const diaryService = new DiaryService();
const getDatesForClub = async (req, res) => {
try {
const { clubId } = req.params;
const { authcode: userToken } = req.headers;
const dates = await diaryService.getDatesForClub(userToken, clubId);
res.status(200).json(dates);
} catch (error) {
console.error('[getDatesForClub] - Error:', error);
res.status(error.statusCode || 500).json({ error: error.message });
}
};
const createDateForClub = async (req, res) => {
try {
const { clubId } = req.params;
const { authcode: userToken } = req.headers;
const { date, trainingStart, trainingEnd } = req.body;
if (!date) {
throw new HttpError('The date field is required', 400);
}
if (isNaN(new Date(date).getTime())) {
throw new HttpError('Invalid date format', 400);
}
const newDate = await diaryService.createDateForClub(userToken, clubId, date, trainingStart, trainingEnd);
res.status(201).json(newDate);
} catch (error) {
console.error('[createDateForClub] - Error:', error);
res.status(error.statusCode || 500).json({ error: error.message });
}
};
const updateTrainingTimes = async (req, res) => {
try {
const { clubId } = req.params;
const { authcode: userToken } = req.headers;
const { date, trainingStart, trainingEnd } = req.body;
if (!date || !trainingStart || !trainingEnd) {
throw new HttpError('All fields (date, trainingStart, trainingEnd) are required', 400);
}
const updatedDate = await diaryService.updateTrainingTimes(userToken, clubId, date, trainingStart, trainingEnd);
res.status(200).json(updatedDate);
} catch (error) {
console.error('[updateTrainingTimes] - Error:', error);
res.status(error.statusCode || 500).json({ error: error.message });
}
};
export { getDatesForClub, createDateForClub, updateTrainingTimes };

View File

@@ -1,19 +1,40 @@
import MemberService from "../services/memberService.js";
const getClubMembers = async(req, res) => {
const { clubid: clubId } = req.body;
res.status(200).json(MemberService.getClubMembers(clubId));
try {
const { authcode: userToken } = req.headers;
const { id: clubId } = req.params;
console.log('[getClubMembers]', userToken, clubId);
res.status(200).json(await MemberService.getClubMembers(userToken, clubId));
} catch(error) {
console.log('[getClubMembers] - Error: ', error);
res.status(500).json({ error: 'systemerror' });
}
}
const getWaitingApprovals = async(req, res) => {
try {
const { clubid: clubId } = req.params;
const { authcode: userToken} = req.headers;
const waitingApprovals = MemberService.getApprovalRequests(userToken, clubId);
console.log('[getWaitingApprovals] - Start');
const { id: clubId } = req.params;
console.log('[getWaitingApprovals] - get token');
const { authcode: userToken } = req.headers;
console.log('[getWaitingApprovals] - load for waiting approvals');
const waitingApprovals = await MemberService.getApprovalRequests(userToken, clubId);
console.log('[getWaitingApprovals] - set response');
res.status(200).json(waitingApprovals);
console.log('[getWaitingApprovals] - done');
} catch(error) {
console.log('[getWaitingApprovals] - Error: ', error);
res.status(403).json({ error: error });
}
}
const setClubMembers = async(req, res) => {
const { id: memberId, firstname: firstName, lastname: lastName, street, city, birthdate, phone, email} = req.body;
const { id: clubId } = req.params;
const { authcode: userToken } = req.headers;
const addResult = await MemberService.setClubMember(userToken, clubId, memberId, firstName, lastName, street, city, birthdate, phone, email);
res.status(addResult.status || 500).json(addResult.response);
}
export { getClubMembers, getWaitingApprovals };
export { getClubMembers, getWaitingApprovals, setClubMembers };

View File

@@ -2,7 +2,7 @@ import { Sequelize } from 'sequelize';
import { development } from './config.js';
const sequelize = new Sequelize(
development.database,
development.database,
development.username,
development.password,
{

View File

@@ -0,0 +1,10 @@
class HttpError extends Error {
constructor(message, statusCode) {
super(message);
this.name = this.constructor.name;
this.statusCode = statusCode;
Error.captureStackTrace(this, this.constructor);
}
}
export default HttpError;

View File

@@ -1,13 +1,17 @@
import User from '../models/User.js';
export const authenticate = async (req, res, next) => {
const { userid: userId, authcode: authCode } = req.headers;
if (!userId || !authCode) {
return res.status(401).json({ error: 'Unauthorized: Missing credentials' });
try {
const { userid: userId, authcode: authCode } = req.headers;
if (!userId || !authCode) {
return res.status(401).json({ error: 'Unauthorized: Missing credentials' });
}
const user = await User.findOne({ where: { email: userId, authCode: authCode } });
if (!user) {
return res.status(401).json({ error: 'Unauthorized: Invalid credentials' });
}
next();
} catch(error) {
return res.status(500).json({ error: 'Internal Server Error at auth' });
}
const user = await User.findOne({ where: { email: userId, hashedId: authCode } });
if (!user) {
return res.status(401).json({ error: 'Unauthorized: Invalid credentials' });
}
next();
};

View File

@@ -7,6 +7,10 @@ const Club = sequelize.define('Club', {
allowNull: false,
unique: true,
},
}, {
tableName: 'clubs',
underscored: true,
timestamps: true
});
export default Club;

View File

@@ -0,0 +1,34 @@
import { DataTypes } from 'sequelize';
import sequelize from '../database.js';
import Club from './Club.js'; // Importiere das Club-Modell
const DiaryDate = sequelize.define('DiaryDate', {
date: {
type: DataTypes.DATEONLY,
allowNull: false,
},
clubId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: Club,
key: 'id'
},
onDelete: 'CASCADE',
},
trainingStart: {
type: DataTypes.TIME,
allowNull: true,
},
trainingEnd: {
type: DataTypes.TIME,
allowNull: true,
}
}, {
tableName: 'diary_dates',
underscored: true,
timestamps: true
});
export default DiaryDate;

View File

@@ -7,20 +7,18 @@ const Log = sequelize.define('Log', {
type: DataTypes.STRING,
allowNull: false,
},
timestamp: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
},
userId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: User,
model: 'user',
key: 'id',
},
},
},
{
underscored: true
}, {
underscored: true,
tableName: 'log',
timestamps: true
});
export default Log;

View File

@@ -1,12 +1,10 @@
const { DataTypes, Model } = require('sequelize');
const crypto = require('crypto');
const sequelize = require('../database');
const Club = require('./Club');
const { encryptData, decryptData } = require('../utils/encrypt');
import { DataTypes, Model } from 'sequelize';
import crypto from 'crypto';
import sequelize from '../database.js';
import Club from './Club.js';
import { encryptData, decryptData } from '../utils/encrypt.js';
class Member extends Model {}
Member.init({
const Member = sequelize.define('User', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
@@ -18,18 +16,30 @@ Member.init({
unique: true,
allowNull: false,
defaultValue() {
return crypto.randomBytes(16).toString('hex');
return crypto.randomBytes(64).toString('hex');
}
},
name: {
firstName: {
type: DataTypes.STRING,
allowNull: false,
set(value) {
const encryptedValue = encryptData(value);
this.setDataValue('name', encryptedValue);
this.setDataValue('firstName', encryptedValue);
},
get() {
const encryptedValue = this.getDataValue('name');
const encryptedValue = this.getDataValue('firstName');
return decryptData(encryptedValue);
}
},
lastName: {
type: DataTypes.STRING,
allowNull: false,
set(value) {
const encryptedValue = encryptData(value);
this.setDataValue('lastName', encryptedValue);
},
get() {
const encryptedValue = this.getDataValue('lastName');
return decryptData(encryptedValue);
}
},
@@ -80,27 +90,50 @@ Member.init({
const encryptedValue = this.getDataValue('city');
return decryptData(encryptedValue);
}
},
email: {
type: DataTypes.STRING,
allowNull: false,
set(value) {
const encryptedValue = encryptData(value);
this.setDataValue('email', encryptedValue);
},
get() {
const encryptedValue = this.getDataValue('email');
return decryptData(encryptedValue);
}
},
clubId: {
type: DataTypes.INTEGER,
allowNull: false,
},
active: {
type: DataTypes.BOOLEAN,
allowNull: false,
default: true,
}
}, {
underscored: true,
sequelize,
modelName: 'Member',
tableName: 'members',
tableName: 'member',
timestamps: true,
hooks: {
beforeCreate: (member) => {
afterCreate: (member) => {
member.hashedId = crypto.createHash('sha256').update(String(member.id)).digest('hex');
member.save();
},
beforeUpdate: (member) => {
if (member.changed('id')) {
member.hashedId = crypto.createHash('sha256').update(String(member.id)).digest('hex');
}
}
}
});
},
{
underscored: true,
tableName: 'log',
timestamps: true
}
);
Member.belongsTo(Club);
Club.hasMany(Member);
Member.belongsTo(Club, { as: 'club' });
Club.hasMany(Member, { as: 'members' });
module.exports = Member;
export default Member;

View File

@@ -3,6 +3,12 @@ import sequelize from '../database.js';
import bcrypt from 'bcrypt';
const User = sequelize.define('User', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false
},
hashedId: {
type: DataTypes.STRING(1024),
allowNull: true,
@@ -16,6 +22,10 @@ const User = sequelize.define('User', {
type: DataTypes.STRING,
allowNull: false,
},
salt: {
type: DataTypes.STRING,
allowNull: true,
},
activationCode: {
type: DataTypes.STRING,
allowNull: true,
@@ -30,20 +40,27 @@ const User = sequelize.define('User', {
}
}, {
underscored: true,
table: 'user',
tableName: 'user',
timestamps: true,
hooks: {
beforeCreate: async (user) => {
const salt = await bcrypt.genSalt(10);
user.salt = salt;
console.log(user);
user.password = await bcrypt.hash(user.password, salt);
},
beforeUpdate: async (user) => {
if (user.changed('password')) {
const salt = await bcrypt.genSalt(10);
user.password = await bcrypt.hash(user.password, salt);
if (!user.password.startsWith('$2b$') && !user.password.startsWith('$2a$')) {
const salt = user.salt;
user.password = await bcrypt.hash(user.password, salt);
}
}
},
afterCreate: async (user) => {
user.hashedId = bcrypt.hash(user.id.toString());
const salt = await bcrypt.genSalt(10);
user.hashedId = await bcrypt.hash(user.id.toString(), salt);
await user.save();
}
},
});

View File

@@ -23,7 +23,9 @@ const UserClub = sequelize.define('UserClub', {
defaultValue: false,
},
}, {
underscored: true
underscored: true,
tableName: 'user_club',
timestamps: true
});
User.belongsToMany(Club, { through: UserClub, foreignKey: 'userId' });

View File

@@ -2,6 +2,7 @@ import User from './User.js';
import Log from './Log.js';
import Club from './Club.js';
import UserClub from './UserClub.js';
import DiaryDate from './DiaryDates.js';
User.hasMany(Log, { foreignKey: 'userId' });
Log.belongsTo(User, { foreignKey: 'userId' });
@@ -9,4 +10,7 @@ Log.belongsTo(User, { foreignKey: 'userId' });
User.belongsToMany(Club, { through: UserClub, foreignKey: 'userId' });
Club.belongsToMany(User, { through: UserClub, foreignKey: 'clubId' });
DiaryDate.belongsTo(Club, { foreignKey: 'clubId' });
Club.hasMany(DiaryDate, { foreignKey: 'clubId' });
export { User, Log, Club, UserClub };

View File

@@ -1,16 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../color-support/bin.js" "$@"
else
exec node "$basedir/../color-support/bin.js" "$@"
fi

1
backend/node_modules/.bin/color-support generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../color-support/bin.js

View File

@@ -1,17 +0,0 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\color-support\bin.js" %*

View File

@@ -1,28 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../color-support/bin.js" $args
} else {
& "$basedir/node$exe" "$basedir/../color-support/bin.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../color-support/bin.js" $args
} else {
& "node$exe" "$basedir/../color-support/bin.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

16
backend/node_modules/.bin/mime generated vendored
View File

@@ -1,16 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../mime/cli.js" "$@"
else
exec node "$basedir/../mime/cli.js" "$@"
fi

1
backend/node_modules/.bin/mime generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../mime/cli.js

17
backend/node_modules/.bin/mime.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mime\cli.js" %*

28
backend/node_modules/.bin/mime.ps1 generated vendored
View File

@@ -1,28 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../mime/cli.js" $args
} else {
& "$basedir/node$exe" "$basedir/../mime/cli.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../mime/cli.js" $args
} else {
& "node$exe" "$basedir/../mime/cli.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

16
backend/node_modules/.bin/mkdirp generated vendored
View File

@@ -1,16 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../mkdirp/bin/cmd.js" "$@"
else
exec node "$basedir/../mkdirp/bin/cmd.js" "$@"
fi

1
backend/node_modules/.bin/mkdirp generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../mkdirp/bin/cmd.js

17
backend/node_modules/.bin/mkdirp.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mkdirp\bin\cmd.js" %*

28
backend/node_modules/.bin/mkdirp.ps1 generated vendored
View File

@@ -1,28 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
} else {
& "$basedir/node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
} else {
& "node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

View File

@@ -1,16 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../@mapbox/node-pre-gyp/bin/node-pre-gyp" "$@"
else
exec node "$basedir/../@mapbox/node-pre-gyp/bin/node-pre-gyp" "$@"
fi

1
backend/node_modules/.bin/node-pre-gyp generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../@mapbox/node-pre-gyp/bin/node-pre-gyp

View File

@@ -1,17 +0,0 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\@mapbox\node-pre-gyp\bin\node-pre-gyp" %*

View File

@@ -1,28 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../@mapbox/node-pre-gyp/bin/node-pre-gyp" $args
} else {
& "$basedir/node$exe" "$basedir/../@mapbox/node-pre-gyp/bin/node-pre-gyp" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../@mapbox/node-pre-gyp/bin/node-pre-gyp" $args
} else {
& "node$exe" "$basedir/../@mapbox/node-pre-gyp/bin/node-pre-gyp" $args
}
$ret=$LASTEXITCODE
}
exit $ret

16
backend/node_modules/.bin/nodemon generated vendored
View File

@@ -1,16 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../nodemon/bin/nodemon.js" "$@"
else
exec node "$basedir/../nodemon/bin/nodemon.js" "$@"
fi

1
backend/node_modules/.bin/nodemon generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../nodemon/bin/nodemon.js

View File

@@ -1,17 +0,0 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\nodemon\bin\nodemon.js" %*

View File

@@ -1,28 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
} else {
& "$basedir/node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
} else {
& "node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

16
backend/node_modules/.bin/nodetouch generated vendored
View File

@@ -1,16 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../touch/bin/nodetouch.js" "$@"
else
exec node "$basedir/../touch/bin/nodetouch.js" "$@"
fi

1
backend/node_modules/.bin/nodetouch generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../touch/bin/nodetouch.js

View File

@@ -1,17 +0,0 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\touch\bin\nodetouch.js" %*

View File

@@ -1,28 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../touch/bin/nodetouch.js" $args
} else {
& "$basedir/node$exe" "$basedir/../touch/bin/nodetouch.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../touch/bin/nodetouch.js" $args
} else {
& "node$exe" "$basedir/../touch/bin/nodetouch.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

16
backend/node_modules/.bin/nopt generated vendored
View File

@@ -1,16 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../nopt/bin/nopt.js" "$@"
else
exec node "$basedir/../nopt/bin/nopt.js" "$@"
fi

1
backend/node_modules/.bin/nopt generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../nopt/bin/nopt.js

17
backend/node_modules/.bin/nopt.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\nopt\bin\nopt.js" %*

28
backend/node_modules/.bin/nopt.ps1 generated vendored
View File

@@ -1,28 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../nopt/bin/nopt.js" $args
} else {
& "$basedir/node$exe" "$basedir/../nopt/bin/nopt.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../nopt/bin/nopt.js" $args
} else {
& "node$exe" "$basedir/../nopt/bin/nopt.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

16
backend/node_modules/.bin/rimraf generated vendored
View File

@@ -1,16 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../rimraf/bin.js" "$@"
else
exec node "$basedir/../rimraf/bin.js" "$@"
fi

1
backend/node_modules/.bin/rimraf generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../rimraf/bin.js

17
backend/node_modules/.bin/rimraf.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\rimraf\bin.js" %*

28
backend/node_modules/.bin/rimraf.ps1 generated vendored
View File

@@ -1,28 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../rimraf/bin.js" $args
} else {
& "$basedir/node$exe" "$basedir/../rimraf/bin.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../rimraf/bin.js" $args
} else {
& "node$exe" "$basedir/../rimraf/bin.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

16
backend/node_modules/.bin/semver generated vendored
View File

@@ -1,16 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../semver/bin/semver.js" "$@"
else
exec node "$basedir/../semver/bin/semver.js" "$@"
fi

1
backend/node_modules/.bin/semver generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../semver/bin/semver.js

17
backend/node_modules/.bin/semver.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\semver\bin\semver.js" %*

28
backend/node_modules/.bin/semver.ps1 generated vendored
View File

@@ -1,28 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
} else {
& "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../semver/bin/semver.js" $args
} else {
& "node$exe" "$basedir/../semver/bin/semver.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

16
backend/node_modules/.bin/uuid generated vendored
View File

@@ -1,16 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../uuid/dist/bin/uuid" "$@"
else
exec node "$basedir/../uuid/dist/bin/uuid" "$@"
fi

1
backend/node_modules/.bin/uuid generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../uuid/dist/bin/uuid

17
backend/node_modules/.bin/uuid.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\uuid\dist\bin\uuid" %*

28
backend/node_modules/.bin/uuid.ps1 generated vendored
View File

@@ -1,28 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../uuid/dist/bin/uuid" $args
} else {
& "$basedir/node$exe" "$basedir/../uuid/dist/bin/uuid" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../uuid/dist/bin/uuid" $args
} else {
& "node$exe" "$basedir/../uuid/dist/bin/uuid" $args
}
$ret=$LASTEXITCODE
}
exit $ret

0
backend/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp generated vendored Normal file → Executable file
View File

View File

@@ -1,13 +1,13 @@
# Installation
> `npm install --save @types/debug`
# Summary
This package contains type definitions for debug (https://github.com/debug-js/debug).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/debug.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/debug/index.d.ts)
````ts
# Installation
> `npm install --save @types/debug`
# Summary
This package contains type definitions for debug (https://github.com/debug-js/debug).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/debug.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/debug/index.d.ts)
````ts
declare var debug: debug.Debug & { debug: debug.Debug; default: debug.Debug };
export = debug;
@@ -58,12 +58,12 @@ declare namespace debug {
extend: (namespace: string, delimiter?: string) => Debugger;
}
}
````
### Additional Details
* Last updated: Thu, 09 Nov 2023 03:06:57 GMT
* Dependencies: [@types/ms](https://npmjs.com/package/@types/ms)
# Credits
These definitions were written by [Seon-Wook Park](https://github.com/swook), [Gal Talmor](https://github.com/galtalmor), [John McLaughlin](https://github.com/zamb3zi), [Brasten Sager](https://github.com/brasten), [Nicolas Penin](https://github.com/npenin), [Kristian Brünn](https://github.com/kristianmitk), and [Caleb Gregory](https://github.com/calebgregory).
````
### Additional Details
* Last updated: Thu, 09 Nov 2023 03:06:57 GMT
* Dependencies: [@types/ms](https://npmjs.com/package/@types/ms)
# Credits
These definitions were written by [Seon-Wook Park](https://github.com/swook), [Gal Talmor](https://github.com/galtalmor), [John McLaughlin](https://github.com/zamb3zi), [Brasten Sager](https://github.com/brasten), [Nicolas Penin](https://github.com/npenin), [Kristian Brünn](https://github.com/kristianmitk), and [Caleb Gregory](https://github.com/calebgregory).

View File

@@ -1,13 +1,13 @@
# Installation
> `npm install --save @types/ms`
# Summary
This package contains type definitions for ms (https://github.com/zeit/ms).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ms.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ms/index.d.ts)
````ts
# Installation
> `npm install --save @types/ms`
# Summary
This package contains type definitions for ms (https://github.com/zeit/ms).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ms.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ms/index.d.ts)
````ts
/**
* Short/Long format for `value`.
*
@@ -26,12 +26,12 @@ declare function ms(value: number, options?: { long: boolean }): string;
declare function ms(value: string): number;
export = ms;
````
### Additional Details
* Last updated: Tue, 07 Nov 2023 09:09:39 GMT
* Dependencies: none
# Credits
These definitions were written by [Zhiyuan Wang](https://github.com/danny8002).
````
### Additional Details
* Last updated: Tue, 07 Nov 2023 09:09:39 GMT
* Dependencies: none
# Credits
These definitions were written by [Zhiyuan Wang](https://github.com/danny8002).

View File

@@ -1,15 +1,15 @@
# Installation
> `npm install --save @types/node`
# Summary
This package contains type definitions for node (https://nodejs.org/).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
### Additional Details
* Last updated: Tue, 23 Jul 2024 18:09:25 GMT
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
# Credits
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky).
# Installation
> `npm install --save @types/node`
# Summary
This package contains type definitions for node (https://nodejs.org/).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
### Additional Details
* Last updated: Tue, 23 Jul 2024 18:09:25 GMT
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
# Credits
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky).

View File

@@ -1,15 +1,15 @@
# Installation
> `npm install --save @types/validator`
# Summary
This package contains type definitions for validator (https://github.com/validatorjs/validator.js).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/validator.
### Additional Details
* Last updated: Sun, 16 Jun 2024 11:35:49 GMT
* Dependencies: none
# Credits
These definitions were written by [tgfjt](https://github.com/tgfjt), [Ilya Mochalov](https://github.com/chrootsu), [Ayman Nedjmeddine](https://github.com/IOAyman), [Louay Alakkad](https://github.com/louy), [Bonggyun Lee](https://github.com/deptno), [Naoto Yokoyama](https://github.com/builtinnya), [Philipp Katz](https://github.com/qqilihq), [Jace Warren](https://github.com/keatz55), [Munif Tanjim](https://github.com/MunifTanjim), [Vlad Poluch](https://github.com/vlapo), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Matteo Nista](https://github.com/Mattewn99), [Roman Babiak](https://github.com/Almost-Infinity), and [Daniel Freire](https://github.com/dcfreire).
# Installation
> `npm install --save @types/validator`
# Summary
This package contains type definitions for validator (https://github.com/validatorjs/validator.js).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/validator.
### Additional Details
* Last updated: Sun, 16 Jun 2024 11:35:49 GMT
* Dependencies: none
# Credits
These definitions were written by [tgfjt](https://github.com/tgfjt), [Ilya Mochalov](https://github.com/chrootsu), [Ayman Nedjmeddine](https://github.com/IOAyman), [Louay Alakkad](https://github.com/louy), [Bonggyun Lee](https://github.com/deptno), [Naoto Yokoyama](https://github.com/builtinnya), [Philipp Katz](https://github.com/qqilihq), [Jace Warren](https://github.com/keatz55), [Munif Tanjim](https://github.com/MunifTanjim), [Vlad Poluch](https://github.com/vlapo), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Matteo Nista](https://github.com/Mattewn99), [Roman Babiak](https://github.com/Almost-Infinity), and [Daniel Freire](https://github.com/dcfreire).

0
backend/node_modules/aws-ssl-profiles/package.json generated vendored Normal file → Executable file
View File

View File

@@ -1,39 +1,39 @@
environment:
matrix:
- nodejs_version: "14"
platform: x64
- nodejs_version: "14"
platform: x86
- nodejs_version: "16"
platform: x64
- nodejs_version: "16"
platform: x86
- nodejs_version: "18"
platform: x64
install:
- where npm
- where node
- ps: Install-Product node $env:nodejs_version $env:platform
build: off
artifacts:
- path: 'build/stage/**/bcrypt*.tar.gz'
test_script:
- node --version
- npm --version
- npm test
after_test:
- .\node_modules\.bin\node-pre-gyp package
on_success:
- ps: >
if ($env:NODE_PRE_GYP_GITHUB_TOKEN -ne $null -and $env:APPVEYOR_REPO_TAG_NAME -match '^v(0|[1-9]+)\.(0|[1-9]+)\.(0|[1-9]+)(-\w)?$') {
echo "Publishing $env:APPVEYOR_REPO_TAG_NAME"
npm install node-pre-gyp-github@1.4.3
./node_modules/.bin/node-pre-gyp-github publish --release
}
environment:
matrix:
- nodejs_version: "14"
platform: x64
- nodejs_version: "14"
platform: x86
- nodejs_version: "16"
platform: x64
- nodejs_version: "16"
platform: x86
- nodejs_version: "18"
platform: x64
install:
- where npm
- where node
- ps: Install-Product node $env:nodejs_version $env:platform
build: off
artifacts:
- path: 'build/stage/**/bcrypt*.tar.gz'
test_script:
- node --version
- npm --version
- npm test
after_test:
- .\node_modules\.bin\node-pre-gyp package
on_success:
- ps: >
if ($env:NODE_PRE_GYP_GITHUB_TOKEN -ne $null -and $env:APPVEYOR_REPO_TAG_NAME -match '^v(0|[1-9]+)\.(0|[1-9]+)\.(0|[1-9]+)(-\w)?$') {
echo "Publishing $env:APPVEYOR_REPO_TAG_NAME"
npm install node-pre-gyp-github@1.4.3
./node_modules/.bin/node-pre-gyp-github publish --release
}

BIN
backend/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node generated vendored Normal file → Executable file

Binary file not shown.

0
backend/node_modules/bcrypt/test-docker.sh generated vendored Normal file → Executable file
View File

0
backend/node_modules/color-support/bin.js generated vendored Normal file → Executable file
View File

View File

@@ -1,16 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../semver/bin/semver.js" "$@"
else
exec node "$basedir/../semver/bin/semver.js" "$@"
fi

1
backend/node_modules/make-dir/node_modules/.bin/semver generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../semver/bin/semver.js

View File

@@ -1,17 +0,0 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\semver\bin\semver.js" %*

View File

@@ -1,28 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
} else {
& "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../semver/bin/semver.js" $args
} else {
& "node$exe" "$basedir/../semver/bin/semver.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

0
backend/node_modules/make-dir/node_modules/semver/bin/semver.js generated vendored Normal file → Executable file
View File

0
backend/node_modules/mime/cli.js generated vendored Normal file → Executable file
View File

0
backend/node_modules/mime/src/build.js generated vendored Normal file → Executable file
View File

0
backend/node_modules/mkdirp/bin/cmd.js generated vendored Normal file → Executable file
View File

0
backend/node_modules/node-addon-api/tools/conversion.js generated vendored Normal file → Executable file
View File

0
backend/node_modules/nodemon/bin/nodemon.js generated vendored Normal file → Executable file
View File

0
backend/node_modules/nopt/bin/nopt.js generated vendored Normal file → Executable file
View File

0
backend/node_modules/rimraf/bin.js generated vendored Normal file → Executable file
View File

0
backend/node_modules/semver/bin/semver.js generated vendored Normal file → Executable file
View File

View File

@@ -272,17 +272,11 @@ exports.now = now;
const TICK_CHAR = "`";
exports.TICK_CHAR = TICK_CHAR;
function addTicks(s, tickChar) {
if (typeof s !== 'string') {
return s;
}
tickChar = tickChar || TICK_CHAR;
return tickChar + removeTicks(s, tickChar) + tickChar;
}
exports.addTicks = addTicks;
function removeTicks(s, tickChar) {
if (typeof s !== 'string') {
return s;
}
tickChar = tickChar || TICK_CHAR;
return s.replace(new RegExp(tickChar, "g"), "");
}

View File

@@ -7,59 +7,59 @@ var path = require('path');
var fs = require('fs');
var https = require('https');
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
var packageJson = process$1.env.npm_package_json;

0
backend/node_modules/touch/bin/nodetouch.js generated vendored Normal file → Executable file
View File

0
backend/node_modules/uuid/dist/bin/uuid generated vendored Normal file → Executable file
View File

0
backend/node_modules/validator/es/lib/isCurrency.js generated vendored Normal file → Executable file
View File

View File

@@ -46,8 +46,8 @@ var PT = function PT(str) {
return checksum === parseInt(tin[8], 10);
};
export var vatMatchers = {
/**
* European Union VAT identification numbers
/**
* European Union VAT identification numbers
*/
AT: function AT(str) {
return /^(AT)?U\d{8}$/.test(str);
@@ -128,8 +128,8 @@ export var vatMatchers = {
SE: function SE(str) {
return /^(SE)?\d{12}$/.test(str);
},
/**
* VAT numbers of non-EU countries
/**
* VAT numbers of non-EU countries
*/
AL: function AL(str) {
return /^(AL)?\w{9}[A-Z]$/.test(str);
@@ -196,8 +196,8 @@ export var vatMatchers = {
UZ: function UZ(str) {
return /^(UZ)?\d{9}$/.test(str);
},
/**
* VAT numbers of Latin American countries
/**
* VAT numbers of Latin American countries
*/
AR: function AR(str) {
return /^(AR)?\d{11}$/.test(str);

0
backend/node_modules/validator/lib/isCurrency.js generated vendored Normal file → Executable file
View File

View File

@@ -57,8 +57,8 @@ var PT = function PT(str) {
return checksum === parseInt(tin[8], 10);
};
var vatMatchers = exports.vatMatchers = {
/**
* European Union VAT identification numbers
/**
* European Union VAT identification numbers
*/
AT: function AT(str) {
return /^(AT)?U\d{8}$/.test(str);
@@ -139,8 +139,8 @@ var vatMatchers = exports.vatMatchers = {
SE: function SE(str) {
return /^(SE)?\d{12}$/.test(str);
},
/**
* VAT numbers of non-EU countries
/**
* VAT numbers of non-EU countries
*/
AL: function AL(str) {
return /^(AL)?\w{9}[A-Z]$/.test(str);
@@ -207,8 +207,8 @@ var vatMatchers = exports.vatMatchers = {
UZ: function UZ(str) {
return /^(UZ)?\d{9}$/.test(str);
},
/**
* VAT numbers of Latin American countries
/**
* VAT numbers of Latin American countries
*/
AR: function AR(str) {
return /^(AR)?\d{11}$/.test(str);

View File

@@ -5228,8 +5228,8 @@ var PT = function PT(str) {
return checksum === parseInt(tin[8], 10);
};
var vatMatchers = {
/**
* European Union VAT identification numbers
/**
* European Union VAT identification numbers
*/
AT: function AT(str) {
return /^(AT)?U\d{8}$/.test(str);
@@ -5310,8 +5310,8 @@ var vatMatchers = {
SE: function SE(str) {
return /^(SE)?\d{12}$/.test(str);
},
/**
* VAT numbers of non-EU countries
/**
* VAT numbers of non-EU countries
*/
AL: function AL(str) {
return /^(AL)?\w{9}[A-Z]$/.test(str);
@@ -5378,8 +5378,8 @@ var vatMatchers = {
UZ: function UZ(str) {
return /^(UZ)?\d{9}$/.test(str);
},
/**
* VAT numbers of Latin American countries
/**
* VAT numbers of Latin American countries
*/
AR: function AR(str) {
return /^(AR)?\d{11}$/.test(str);

File diff suppressed because it is too large Load Diff

0
backend/node_modules/wide-align/LICENSE generated vendored Normal file → Executable file
View File

0
backend/node_modules/wide-align/README.md generated vendored Normal file → Executable file
View File

0
backend/node_modules/wide-align/align.js generated vendored Normal file → Executable file
View File

0
backend/node_modules/wide-align/package.json generated vendored Normal file → Executable file
View File

40
backend/node_modules/wkx/LICENSE.txt generated vendored
View File

@@ -1,20 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Christian Schwarz
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The MIT License (MIT)
Copyright (c) 2013 Christian Schwarz
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

184
backend/node_modules/wkx/README.md generated vendored
View File

@@ -1,92 +1,92 @@
wkx [![Build Status](https://travis-ci.org/cschwarz/wkx.svg?branch=master)](https://travis-ci.org/cschwarz/wkx) [![Coverage Status](https://coveralls.io/repos/cschwarz/wkx/badge.svg?branch=master)](https://coveralls.io/r/cschwarz/wkx?branch=master)
========
A WKT/WKB/EWKT/EWKB/TWKB/GeoJSON parser and serializer with support for
- Point
- LineString
- Polygon
- MultiPoint
- MultiLineString
- MultiPolygon
- GeometryCollection
Examples
--------
The following examples show you how to work with wkx.
```javascript
var wkx = require('wkx');
//Parsing a WKT string
var geometry = wkx.Geometry.parse('POINT(1 2)');
//Parsing an EWKT string
var geometry = wkx.Geometry.parse('SRID=4326;POINT(1 2)');
//Parsing a node Buffer containing a WKB object
var geometry = wkx.Geometry.parse(wkbBuffer);
//Parsing a node Buffer containing an EWKB object
var geometry = wkx.Geometry.parse(ewkbBuffer);
//Parsing a node Buffer containing a TWKB object
var geometry = wkx.Geometry.parseTwkb(twkbBuffer);
//Parsing a GeoJSON object
var geometry = wkx.Geometry.parseGeoJSON({ type: 'Point', coordinates: [1, 2] });
//Serializing a Point geometry to WKT
var wktString = new wkx.Point(1, 2).toWkt();
//Serializing a Point geometry to WKB
var wkbBuffer = new wkx.Point(1, 2).toWkb();
//Serializing a Point geometry to EWKT
var ewktString = new wkx.Point(1, 2, undefined, undefined, 4326).toEwkt();
//Serializing a Point geometry to EWKB
var ewkbBuffer = new wkx.Point(1, 2, undefined, undefined, 4326).toEwkb();
//Serializing a Point geometry to TWKB
var twkbBuffer = new wkx.Point(1, 2).toTwkb();
//Serializing a Point geometry to GeoJSON
var geoJSONObject = new wkx.Point(1, 2).toGeoJSON();
```
Browser
-------
To use `wkx` in a webpage, simply copy a built browser version from `dist/` into your project, and use a `script` tag
to include it:
```html
<script src="wkx.js"></script>
```
If you use [browserify][] for your project, you can simply `npm install wkx --save`, and just require `wkx` as usual in
your code.
----
Regardless of which of the preceeding options you choose, using `wkx` in the browser will look the same:
```javascript
var wkx = require('wkx');
var geometry = wkx.Geometry.parse('POINT(1 2)');
console.log(geometry.toGeoJSON());
```
In addition to the `wkx` module, the browser versions also export `buffer`, which is useful for parsing WKB:
```javascript
var Buffer = require('buffer').Buffer;
var wkx = require('wkx');
var wkbBuffer = new Buffer('0101000000000000000000f03f0000000000000040', 'hex');
var geometry = wkx.Geometry.parse(wkbBuffer);
console.log(geometry.toGeoJSON());
```
[browserify]: http://browserify.org/
wkx [![Build Status](https://travis-ci.org/cschwarz/wkx.svg?branch=master)](https://travis-ci.org/cschwarz/wkx) [![Coverage Status](https://coveralls.io/repos/cschwarz/wkx/badge.svg?branch=master)](https://coveralls.io/r/cschwarz/wkx?branch=master)
========
A WKT/WKB/EWKT/EWKB/TWKB/GeoJSON parser and serializer with support for
- Point
- LineString
- Polygon
- MultiPoint
- MultiLineString
- MultiPolygon
- GeometryCollection
Examples
--------
The following examples show you how to work with wkx.
```javascript
var wkx = require('wkx');
//Parsing a WKT string
var geometry = wkx.Geometry.parse('POINT(1 2)');
//Parsing an EWKT string
var geometry = wkx.Geometry.parse('SRID=4326;POINT(1 2)');
//Parsing a node Buffer containing a WKB object
var geometry = wkx.Geometry.parse(wkbBuffer);
//Parsing a node Buffer containing an EWKB object
var geometry = wkx.Geometry.parse(ewkbBuffer);
//Parsing a node Buffer containing a TWKB object
var geometry = wkx.Geometry.parseTwkb(twkbBuffer);
//Parsing a GeoJSON object
var geometry = wkx.Geometry.parseGeoJSON({ type: 'Point', coordinates: [1, 2] });
//Serializing a Point geometry to WKT
var wktString = new wkx.Point(1, 2).toWkt();
//Serializing a Point geometry to WKB
var wkbBuffer = new wkx.Point(1, 2).toWkb();
//Serializing a Point geometry to EWKT
var ewktString = new wkx.Point(1, 2, undefined, undefined, 4326).toEwkt();
//Serializing a Point geometry to EWKB
var ewkbBuffer = new wkx.Point(1, 2, undefined, undefined, 4326).toEwkb();
//Serializing a Point geometry to TWKB
var twkbBuffer = new wkx.Point(1, 2).toTwkb();
//Serializing a Point geometry to GeoJSON
var geoJSONObject = new wkx.Point(1, 2).toGeoJSON();
```
Browser
-------
To use `wkx` in a webpage, simply copy a built browser version from `dist/` into your project, and use a `script` tag
to include it:
```html
<script src="wkx.js"></script>
```
If you use [browserify][] for your project, you can simply `npm install wkx --save`, and just require `wkx` as usual in
your code.
----
Regardless of which of the preceeding options you choose, using `wkx` in the browser will look the same:
```javascript
var wkx = require('wkx');
var geometry = wkx.Geometry.parse('POINT(1 2)');
console.log(geometry.toGeoJSON());
```
In addition to the `wkx` module, the browser versions also export `buffer`, which is useful for parsing WKB:
```javascript
var Buffer = require('buffer').Buffer;
var wkx = require('wkx');
var wkbBuffer = new Buffer('0101000000000000000000f03f0000000000000040', 'hex');
var geometry = wkx.Geometry.parse(wkbBuffer);
console.log(geometry.toGeoJSON());
```
[browserify]: http://browserify.org/

4208
backend/node_modules/wkx/dist/wkx.js generated vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,47 +1,47 @@
module.exports = BinaryReader;
function BinaryReader(buffer, isBigEndian) {
this.buffer = buffer;
this.position = 0;
this.isBigEndian = isBigEndian || false;
}
function _read(readLE, readBE, size) {
return function () {
var value;
if (this.isBigEndian)
value = readBE.call(this.buffer, this.position);
else
value = readLE.call(this.buffer, this.position);
this.position += size;
return value;
};
}
BinaryReader.prototype.readUInt8 = _read(Buffer.prototype.readUInt8, Buffer.prototype.readUInt8, 1);
BinaryReader.prototype.readUInt16 = _read(Buffer.prototype.readUInt16LE, Buffer.prototype.readUInt16BE, 2);
BinaryReader.prototype.readUInt32 = _read(Buffer.prototype.readUInt32LE, Buffer.prototype.readUInt32BE, 4);
BinaryReader.prototype.readInt8 = _read(Buffer.prototype.readInt8, Buffer.prototype.readInt8, 1);
BinaryReader.prototype.readInt16 = _read(Buffer.prototype.readInt16LE, Buffer.prototype.readInt16BE, 2);
BinaryReader.prototype.readInt32 = _read(Buffer.prototype.readInt32LE, Buffer.prototype.readInt32BE, 4);
BinaryReader.prototype.readFloat = _read(Buffer.prototype.readFloatLE, Buffer.prototype.readFloatBE, 4);
BinaryReader.prototype.readDouble = _read(Buffer.prototype.readDoubleLE, Buffer.prototype.readDoubleBE, 8);
BinaryReader.prototype.readVarInt = function () {
var nextByte,
result = 0,
bytesRead = 0;
do {
nextByte = this.buffer[this.position + bytesRead];
result += (nextByte & 0x7F) << (7 * bytesRead);
bytesRead++;
} while (nextByte >= 0x80);
this.position += bytesRead;
return result;
};
module.exports = BinaryReader;
function BinaryReader(buffer, isBigEndian) {
this.buffer = buffer;
this.position = 0;
this.isBigEndian = isBigEndian || false;
}
function _read(readLE, readBE, size) {
return function () {
var value;
if (this.isBigEndian)
value = readBE.call(this.buffer, this.position);
else
value = readLE.call(this.buffer, this.position);
this.position += size;
return value;
};
}
BinaryReader.prototype.readUInt8 = _read(Buffer.prototype.readUInt8, Buffer.prototype.readUInt8, 1);
BinaryReader.prototype.readUInt16 = _read(Buffer.prototype.readUInt16LE, Buffer.prototype.readUInt16BE, 2);
BinaryReader.prototype.readUInt32 = _read(Buffer.prototype.readUInt32LE, Buffer.prototype.readUInt32BE, 4);
BinaryReader.prototype.readInt8 = _read(Buffer.prototype.readInt8, Buffer.prototype.readInt8, 1);
BinaryReader.prototype.readInt16 = _read(Buffer.prototype.readInt16LE, Buffer.prototype.readInt16BE, 2);
BinaryReader.prototype.readInt32 = _read(Buffer.prototype.readInt32LE, Buffer.prototype.readInt32BE, 4);
BinaryReader.prototype.readFloat = _read(Buffer.prototype.readFloatLE, Buffer.prototype.readFloatBE, 4);
BinaryReader.prototype.readDouble = _read(Buffer.prototype.readDoubleLE, Buffer.prototype.readDoubleBE, 8);
BinaryReader.prototype.readVarInt = function () {
var nextByte,
result = 0,
bytesRead = 0;
do {
nextByte = this.buffer[this.position + bytesRead];
result += (nextByte & 0x7F) << (7 * bytesRead);
bytesRead++;
} while (nextByte >= 0x80);
this.position += bytesRead;
return result;
};

View File

@@ -1,65 +1,65 @@
module.exports = BinaryWriter;
function BinaryWriter(size, allowResize) {
this.buffer = new Buffer(size);
this.position = 0;
this.allowResize = allowResize;
}
function _write(write, size) {
return function (value, noAssert) {
this.ensureSize(size);
write.call(this.buffer, value, this.position, noAssert);
this.position += size;
};
}
BinaryWriter.prototype.writeUInt8 = _write(Buffer.prototype.writeUInt8, 1);
BinaryWriter.prototype.writeUInt16LE = _write(Buffer.prototype.writeUInt16LE, 2);
BinaryWriter.prototype.writeUInt16BE = _write(Buffer.prototype.writeUInt16BE, 2);
BinaryWriter.prototype.writeUInt32LE = _write(Buffer.prototype.writeUInt32LE, 4);
BinaryWriter.prototype.writeUInt32BE = _write(Buffer.prototype.writeUInt32BE, 4);
BinaryWriter.prototype.writeInt8 = _write(Buffer.prototype.writeInt8, 1);
BinaryWriter.prototype.writeInt16LE = _write(Buffer.prototype.writeInt16LE, 2);
BinaryWriter.prototype.writeInt16BE = _write(Buffer.prototype.writeInt16BE, 2);
BinaryWriter.prototype.writeInt32LE = _write(Buffer.prototype.writeInt32LE, 4);
BinaryWriter.prototype.writeInt32BE = _write(Buffer.prototype.writeInt32BE, 4);
BinaryWriter.prototype.writeFloatLE = _write(Buffer.prototype.writeFloatLE, 4);
BinaryWriter.prototype.writeFloatBE = _write(Buffer.prototype.writeFloatBE, 4);
BinaryWriter.prototype.writeDoubleLE = _write(Buffer.prototype.writeDoubleLE, 8);
BinaryWriter.prototype.writeDoubleBE = _write(Buffer.prototype.writeDoubleBE, 8);
BinaryWriter.prototype.writeBuffer = function (buffer) {
this.ensureSize(buffer.length);
buffer.copy(this.buffer, this.position, 0, buffer.length);
this.position += buffer.length;
};
BinaryWriter.prototype.writeVarInt = function (value) {
var length = 1;
while ((value & 0xFFFFFF80) !== 0) {
this.writeUInt8((value & 0x7F) | 0x80);
value >>>= 7;
length++;
}
this.writeUInt8(value & 0x7F);
return length;
};
BinaryWriter.prototype.ensureSize = function (size) {
if (this.buffer.length < this.position + size) {
if (this.allowResize) {
var tempBuffer = new Buffer(this.position + size);
this.buffer.copy(tempBuffer, 0, 0, this.buffer.length);
this.buffer = tempBuffer;
}
else {
throw new RangeError('index out of range');
}
}
};
module.exports = BinaryWriter;
function BinaryWriter(size, allowResize) {
this.buffer = new Buffer(size);
this.position = 0;
this.allowResize = allowResize;
}
function _write(write, size) {
return function (value, noAssert) {
this.ensureSize(size);
write.call(this.buffer, value, this.position, noAssert);
this.position += size;
};
}
BinaryWriter.prototype.writeUInt8 = _write(Buffer.prototype.writeUInt8, 1);
BinaryWriter.prototype.writeUInt16LE = _write(Buffer.prototype.writeUInt16LE, 2);
BinaryWriter.prototype.writeUInt16BE = _write(Buffer.prototype.writeUInt16BE, 2);
BinaryWriter.prototype.writeUInt32LE = _write(Buffer.prototype.writeUInt32LE, 4);
BinaryWriter.prototype.writeUInt32BE = _write(Buffer.prototype.writeUInt32BE, 4);
BinaryWriter.prototype.writeInt8 = _write(Buffer.prototype.writeInt8, 1);
BinaryWriter.prototype.writeInt16LE = _write(Buffer.prototype.writeInt16LE, 2);
BinaryWriter.prototype.writeInt16BE = _write(Buffer.prototype.writeInt16BE, 2);
BinaryWriter.prototype.writeInt32LE = _write(Buffer.prototype.writeInt32LE, 4);
BinaryWriter.prototype.writeInt32BE = _write(Buffer.prototype.writeInt32BE, 4);
BinaryWriter.prototype.writeFloatLE = _write(Buffer.prototype.writeFloatLE, 4);
BinaryWriter.prototype.writeFloatBE = _write(Buffer.prototype.writeFloatBE, 4);
BinaryWriter.prototype.writeDoubleLE = _write(Buffer.prototype.writeDoubleLE, 8);
BinaryWriter.prototype.writeDoubleBE = _write(Buffer.prototype.writeDoubleBE, 8);
BinaryWriter.prototype.writeBuffer = function (buffer) {
this.ensureSize(buffer.length);
buffer.copy(this.buffer, this.position, 0, buffer.length);
this.position += buffer.length;
};
BinaryWriter.prototype.writeVarInt = function (value) {
var length = 1;
while ((value & 0xFFFFFF80) !== 0) {
this.writeUInt8((value & 0x7F) | 0x80);
value >>>= 7;
length++;
}
this.writeUInt8(value & 0x7F);
return length;
};
BinaryWriter.prototype.ensureSize = function (size) {
if (this.buffer.length < this.position + size) {
if (this.allowResize) {
var tempBuffer = new Buffer(this.position + size);
this.buffer.copy(tempBuffer, 0, 0, this.buffer.length);
this.buffer = tempBuffer;
}
else {
throw new RangeError('index out of range');
}
}
};

View File

@@ -1,384 +1,384 @@
module.exports = Geometry;
var Types = require('./types');
var Point = require('./point');
var LineString = require('./linestring');
var Polygon = require('./polygon');
var MultiPoint = require('./multipoint');
var MultiLineString = require('./multilinestring');
var MultiPolygon = require('./multipolygon');
var GeometryCollection = require('./geometrycollection');
var BinaryReader = require('./binaryreader');
var BinaryWriter = require('./binarywriter');
var WktParser = require('./wktparser');
var ZigZag = require('./zigzag.js');
function Geometry() {
this.srid = undefined;
this.hasZ = false;
this.hasM = false;
}
Geometry.parse = function (value, options) {
var valueType = typeof value;
if (valueType === 'string' || value instanceof WktParser)
return Geometry._parseWkt(value);
else if (Buffer.isBuffer(value) || value instanceof BinaryReader)
return Geometry._parseWkb(value, options);
else
throw new Error('first argument must be a string or Buffer');
};
Geometry._parseWkt = function (value) {
var wktParser,
srid;
if (value instanceof WktParser)
wktParser = value;
else
wktParser = new WktParser(value);
var match = wktParser.matchRegex([/^SRID=(\d+);/]);
if (match)
srid = parseInt(match[1], 10);
var geometryType = wktParser.matchType();
var dimension = wktParser.matchDimension();
var options = {
srid: srid,
hasZ: dimension.hasZ,
hasM: dimension.hasM
};
switch (geometryType) {
case Types.wkt.Point:
return Point._parseWkt(wktParser, options);
case Types.wkt.LineString:
return LineString._parseWkt(wktParser, options);
case Types.wkt.Polygon:
return Polygon._parseWkt(wktParser, options);
case Types.wkt.MultiPoint:
return MultiPoint._parseWkt(wktParser, options);
case Types.wkt.MultiLineString:
return MultiLineString._parseWkt(wktParser, options);
case Types.wkt.MultiPolygon:
return MultiPolygon._parseWkt(wktParser, options);
case Types.wkt.GeometryCollection:
return GeometryCollection._parseWkt(wktParser, options);
}
};
Geometry._parseWkb = function (value, parentOptions) {
var binaryReader,
wkbType,
geometryType,
options = {};
if (value instanceof BinaryReader)
binaryReader = value;
else
binaryReader = new BinaryReader(value);
binaryReader.isBigEndian = !binaryReader.readInt8();
wkbType = binaryReader.readUInt32();
options.hasSrid = (wkbType & 0x20000000) === 0x20000000;
options.isEwkb = (wkbType & 0x20000000) || (wkbType & 0x40000000) || (wkbType & 0x80000000);
if (options.hasSrid)
options.srid = binaryReader.readUInt32();
options.hasZ = false;
options.hasM = false;
if (!options.isEwkb && (!parentOptions || !parentOptions.isEwkb)) {
if (wkbType >= 1000 && wkbType < 2000) {
options.hasZ = true;
geometryType = wkbType - 1000;
}
else if (wkbType >= 2000 && wkbType < 3000) {
options.hasM = true;
geometryType = wkbType - 2000;
}
else if (wkbType >= 3000 && wkbType < 4000) {
options.hasZ = true;
options.hasM = true;
geometryType = wkbType - 3000;
}
else {
geometryType = wkbType;
}
}
else {
if (wkbType & 0x80000000)
options.hasZ = true;
if (wkbType & 0x40000000)
options.hasM = true;
geometryType = wkbType & 0xF;
}
switch (geometryType) {
case Types.wkb.Point:
return Point._parseWkb(binaryReader, options);
case Types.wkb.LineString:
return LineString._parseWkb(binaryReader, options);
case Types.wkb.Polygon:
return Polygon._parseWkb(binaryReader, options);
case Types.wkb.MultiPoint:
return MultiPoint._parseWkb(binaryReader, options);
case Types.wkb.MultiLineString:
return MultiLineString._parseWkb(binaryReader, options);
case Types.wkb.MultiPolygon:
return MultiPolygon._parseWkb(binaryReader, options);
case Types.wkb.GeometryCollection:
return GeometryCollection._parseWkb(binaryReader, options);
default:
throw new Error('GeometryType ' + geometryType + ' not supported');
}
};
Geometry.parseTwkb = function (value) {
var binaryReader,
options = {};
if (value instanceof BinaryReader)
binaryReader = value;
else
binaryReader = new BinaryReader(value);
var type = binaryReader.readUInt8();
var metadataHeader = binaryReader.readUInt8();
var geometryType = type & 0x0F;
options.precision = ZigZag.decode(type >> 4);
options.precisionFactor = Math.pow(10, options.precision);
options.hasBoundingBox = metadataHeader >> 0 & 1;
options.hasSizeAttribute = metadataHeader >> 1 & 1;
options.hasIdList = metadataHeader >> 2 & 1;
options.hasExtendedPrecision = metadataHeader >> 3 & 1;
options.isEmpty = metadataHeader >> 4 & 1;
if (options.hasExtendedPrecision) {
var extendedPrecision = binaryReader.readUInt8();
options.hasZ = (extendedPrecision & 0x01) === 0x01;
options.hasM = (extendedPrecision & 0x02) === 0x02;
options.zPrecision = ZigZag.decode((extendedPrecision & 0x1C) >> 2);
options.zPrecisionFactor = Math.pow(10, options.zPrecision);
options.mPrecision = ZigZag.decode((extendedPrecision & 0xE0) >> 5);
options.mPrecisionFactor = Math.pow(10, options.mPrecision);
}
else {
options.hasZ = false;
options.hasM = false;
}
if (options.hasSizeAttribute)
binaryReader.readVarInt();
if (options.hasBoundingBox) {
var dimensions = 2;
if (options.hasZ)
dimensions++;
if (options.hasM)
dimensions++;
for (var i = 0; i < dimensions; i++) {
binaryReader.readVarInt();
binaryReader.readVarInt();
}
}
switch (geometryType) {
case Types.wkb.Point:
return Point._parseTwkb(binaryReader, options);
case Types.wkb.LineString:
return LineString._parseTwkb(binaryReader, options);
case Types.wkb.Polygon:
return Polygon._parseTwkb(binaryReader, options);
case Types.wkb.MultiPoint:
return MultiPoint._parseTwkb(binaryReader, options);
case Types.wkb.MultiLineString:
return MultiLineString._parseTwkb(binaryReader, options);
case Types.wkb.MultiPolygon:
return MultiPolygon._parseTwkb(binaryReader, options);
case Types.wkb.GeometryCollection:
return GeometryCollection._parseTwkb(binaryReader, options);
default:
throw new Error('GeometryType ' + geometryType + ' not supported');
}
};
Geometry.parseGeoJSON = function (value) {
return Geometry._parseGeoJSON(value);
};
Geometry._parseGeoJSON = function (value, isSubGeometry) {
var geometry;
switch (value.type) {
case Types.geoJSON.Point:
geometry = Point._parseGeoJSON(value); break;
case Types.geoJSON.LineString:
geometry = LineString._parseGeoJSON(value); break;
case Types.geoJSON.Polygon:
geometry = Polygon._parseGeoJSON(value); break;
case Types.geoJSON.MultiPoint:
geometry = MultiPoint._parseGeoJSON(value); break;
case Types.geoJSON.MultiLineString:
geometry = MultiLineString._parseGeoJSON(value); break;
case Types.geoJSON.MultiPolygon:
geometry = MultiPolygon._parseGeoJSON(value); break;
case Types.geoJSON.GeometryCollection:
geometry = GeometryCollection._parseGeoJSON(value); break;
default:
throw new Error('GeometryType ' + value.type + ' not supported');
}
if (value.crs && value.crs.type && value.crs.type === 'name' && value.crs.properties && value.crs.properties.name) {
var crs = value.crs.properties.name;
if (crs.indexOf('EPSG:') === 0)
geometry.srid = parseInt(crs.substring(5));
else if (crs.indexOf('urn:ogc:def:crs:EPSG::') === 0)
geometry.srid = parseInt(crs.substring(22));
else
throw new Error('Unsupported crs: ' + crs);
}
else if (!isSubGeometry) {
geometry.srid = 4326;
}
return geometry;
};
Geometry.prototype.toEwkt = function () {
return 'SRID=' + this.srid + ';' + this.toWkt();
};
Geometry.prototype.toEwkb = function () {
var ewkb = new BinaryWriter(this._getWkbSize() + 4);
var wkb = this.toWkb();
ewkb.writeInt8(1);
ewkb.writeUInt32LE((wkb.slice(1, 5).readUInt32LE(0) | 0x20000000) >>> 0, true);
ewkb.writeUInt32LE(this.srid);
ewkb.writeBuffer(wkb.slice(5));
return ewkb.buffer;
};
Geometry.prototype._getWktType = function (wktType, isEmpty) {
var wkt = wktType;
if (this.hasZ && this.hasM)
wkt += ' ZM ';
else if (this.hasZ)
wkt += ' Z ';
else if (this.hasM)
wkt += ' M ';
if (isEmpty && !this.hasZ && !this.hasM)
wkt += ' ';
if (isEmpty)
wkt += 'EMPTY';
return wkt;
};
Geometry.prototype._getWktCoordinate = function (point) {
var coordinates = point.x + ' ' + point.y;
if (this.hasZ)
coordinates += ' ' + point.z;
if (this.hasM)
coordinates += ' ' + point.m;
return coordinates;
};
Geometry.prototype._writeWkbType = function (wkb, geometryType, parentOptions) {
var dimensionType = 0;
if (typeof this.srid === 'undefined' && (!parentOptions || typeof parentOptions.srid === 'undefined')) {
if (this.hasZ && this.hasM)
dimensionType += 3000;
else if (this.hasZ)
dimensionType += 1000;
else if (this.hasM)
dimensionType += 2000;
}
else {
if (this.hasZ)
dimensionType |= 0x80000000;
if (this.hasM)
dimensionType |= 0x40000000;
}
wkb.writeUInt32LE((dimensionType + geometryType) >>> 0, true);
};
Geometry.getTwkbPrecision = function (xyPrecision, zPrecision, mPrecision) {
return {
xy: xyPrecision,
z: zPrecision,
m: mPrecision,
xyFactor: Math.pow(10, xyPrecision),
zFactor: Math.pow(10, zPrecision),
mFactor: Math.pow(10, mPrecision)
};
};
Geometry.prototype._writeTwkbHeader = function (twkb, geometryType, precision, isEmpty) {
var type = (ZigZag.encode(precision.xy) << 4) + geometryType;
var metadataHeader = (this.hasZ || this.hasM) << 3;
metadataHeader += isEmpty << 4;
twkb.writeUInt8(type);
twkb.writeUInt8(metadataHeader);
if (this.hasZ || this.hasM) {
var extendedPrecision = 0;
if (this.hasZ)
extendedPrecision |= 0x1;
if (this.hasM)
extendedPrecision |= 0x2;
twkb.writeUInt8(extendedPrecision);
}
};
Geometry.prototype.toGeoJSON = function (options) {
var geoJSON = {};
if (this.srid) {
if (options) {
if (options.shortCrs) {
geoJSON.crs = {
type: 'name',
properties: {
name: 'EPSG:' + this.srid
}
};
}
else if (options.longCrs) {
geoJSON.crs = {
type: 'name',
properties: {
name: 'urn:ogc:def:crs:EPSG::' + this.srid
}
};
}
}
}
return geoJSON;
};
module.exports = Geometry;
var Types = require('./types');
var Point = require('./point');
var LineString = require('./linestring');
var Polygon = require('./polygon');
var MultiPoint = require('./multipoint');
var MultiLineString = require('./multilinestring');
var MultiPolygon = require('./multipolygon');
var GeometryCollection = require('./geometrycollection');
var BinaryReader = require('./binaryreader');
var BinaryWriter = require('./binarywriter');
var WktParser = require('./wktparser');
var ZigZag = require('./zigzag.js');
function Geometry() {
this.srid = undefined;
this.hasZ = false;
this.hasM = false;
}
Geometry.parse = function (value, options) {
var valueType = typeof value;
if (valueType === 'string' || value instanceof WktParser)
return Geometry._parseWkt(value);
else if (Buffer.isBuffer(value) || value instanceof BinaryReader)
return Geometry._parseWkb(value, options);
else
throw new Error('first argument must be a string or Buffer');
};
Geometry._parseWkt = function (value) {
var wktParser,
srid;
if (value instanceof WktParser)
wktParser = value;
else
wktParser = new WktParser(value);
var match = wktParser.matchRegex([/^SRID=(\d+);/]);
if (match)
srid = parseInt(match[1], 10);
var geometryType = wktParser.matchType();
var dimension = wktParser.matchDimension();
var options = {
srid: srid,
hasZ: dimension.hasZ,
hasM: dimension.hasM
};
switch (geometryType) {
case Types.wkt.Point:
return Point._parseWkt(wktParser, options);
case Types.wkt.LineString:
return LineString._parseWkt(wktParser, options);
case Types.wkt.Polygon:
return Polygon._parseWkt(wktParser, options);
case Types.wkt.MultiPoint:
return MultiPoint._parseWkt(wktParser, options);
case Types.wkt.MultiLineString:
return MultiLineString._parseWkt(wktParser, options);
case Types.wkt.MultiPolygon:
return MultiPolygon._parseWkt(wktParser, options);
case Types.wkt.GeometryCollection:
return GeometryCollection._parseWkt(wktParser, options);
}
};
Geometry._parseWkb = function (value, parentOptions) {
var binaryReader,
wkbType,
geometryType,
options = {};
if (value instanceof BinaryReader)
binaryReader = value;
else
binaryReader = new BinaryReader(value);
binaryReader.isBigEndian = !binaryReader.readInt8();
wkbType = binaryReader.readUInt32();
options.hasSrid = (wkbType & 0x20000000) === 0x20000000;
options.isEwkb = (wkbType & 0x20000000) || (wkbType & 0x40000000) || (wkbType & 0x80000000);
if (options.hasSrid)
options.srid = binaryReader.readUInt32();
options.hasZ = false;
options.hasM = false;
if (!options.isEwkb && (!parentOptions || !parentOptions.isEwkb)) {
if (wkbType >= 1000 && wkbType < 2000) {
options.hasZ = true;
geometryType = wkbType - 1000;
}
else if (wkbType >= 2000 && wkbType < 3000) {
options.hasM = true;
geometryType = wkbType - 2000;
}
else if (wkbType >= 3000 && wkbType < 4000) {
options.hasZ = true;
options.hasM = true;
geometryType = wkbType - 3000;
}
else {
geometryType = wkbType;
}
}
else {
if (wkbType & 0x80000000)
options.hasZ = true;
if (wkbType & 0x40000000)
options.hasM = true;
geometryType = wkbType & 0xF;
}
switch (geometryType) {
case Types.wkb.Point:
return Point._parseWkb(binaryReader, options);
case Types.wkb.LineString:
return LineString._parseWkb(binaryReader, options);
case Types.wkb.Polygon:
return Polygon._parseWkb(binaryReader, options);
case Types.wkb.MultiPoint:
return MultiPoint._parseWkb(binaryReader, options);
case Types.wkb.MultiLineString:
return MultiLineString._parseWkb(binaryReader, options);
case Types.wkb.MultiPolygon:
return MultiPolygon._parseWkb(binaryReader, options);
case Types.wkb.GeometryCollection:
return GeometryCollection._parseWkb(binaryReader, options);
default:
throw new Error('GeometryType ' + geometryType + ' not supported');
}
};
Geometry.parseTwkb = function (value) {
var binaryReader,
options = {};
if (value instanceof BinaryReader)
binaryReader = value;
else
binaryReader = new BinaryReader(value);
var type = binaryReader.readUInt8();
var metadataHeader = binaryReader.readUInt8();
var geometryType = type & 0x0F;
options.precision = ZigZag.decode(type >> 4);
options.precisionFactor = Math.pow(10, options.precision);
options.hasBoundingBox = metadataHeader >> 0 & 1;
options.hasSizeAttribute = metadataHeader >> 1 & 1;
options.hasIdList = metadataHeader >> 2 & 1;
options.hasExtendedPrecision = metadataHeader >> 3 & 1;
options.isEmpty = metadataHeader >> 4 & 1;
if (options.hasExtendedPrecision) {
var extendedPrecision = binaryReader.readUInt8();
options.hasZ = (extendedPrecision & 0x01) === 0x01;
options.hasM = (extendedPrecision & 0x02) === 0x02;
options.zPrecision = ZigZag.decode((extendedPrecision & 0x1C) >> 2);
options.zPrecisionFactor = Math.pow(10, options.zPrecision);
options.mPrecision = ZigZag.decode((extendedPrecision & 0xE0) >> 5);
options.mPrecisionFactor = Math.pow(10, options.mPrecision);
}
else {
options.hasZ = false;
options.hasM = false;
}
if (options.hasSizeAttribute)
binaryReader.readVarInt();
if (options.hasBoundingBox) {
var dimensions = 2;
if (options.hasZ)
dimensions++;
if (options.hasM)
dimensions++;
for (var i = 0; i < dimensions; i++) {
binaryReader.readVarInt();
binaryReader.readVarInt();
}
}
switch (geometryType) {
case Types.wkb.Point:
return Point._parseTwkb(binaryReader, options);
case Types.wkb.LineString:
return LineString._parseTwkb(binaryReader, options);
case Types.wkb.Polygon:
return Polygon._parseTwkb(binaryReader, options);
case Types.wkb.MultiPoint:
return MultiPoint._parseTwkb(binaryReader, options);
case Types.wkb.MultiLineString:
return MultiLineString._parseTwkb(binaryReader, options);
case Types.wkb.MultiPolygon:
return MultiPolygon._parseTwkb(binaryReader, options);
case Types.wkb.GeometryCollection:
return GeometryCollection._parseTwkb(binaryReader, options);
default:
throw new Error('GeometryType ' + geometryType + ' not supported');
}
};
Geometry.parseGeoJSON = function (value) {
return Geometry._parseGeoJSON(value);
};
Geometry._parseGeoJSON = function (value, isSubGeometry) {
var geometry;
switch (value.type) {
case Types.geoJSON.Point:
geometry = Point._parseGeoJSON(value); break;
case Types.geoJSON.LineString:
geometry = LineString._parseGeoJSON(value); break;
case Types.geoJSON.Polygon:
geometry = Polygon._parseGeoJSON(value); break;
case Types.geoJSON.MultiPoint:
geometry = MultiPoint._parseGeoJSON(value); break;
case Types.geoJSON.MultiLineString:
geometry = MultiLineString._parseGeoJSON(value); break;
case Types.geoJSON.MultiPolygon:
geometry = MultiPolygon._parseGeoJSON(value); break;
case Types.geoJSON.GeometryCollection:
geometry = GeometryCollection._parseGeoJSON(value); break;
default:
throw new Error('GeometryType ' + value.type + ' not supported');
}
if (value.crs && value.crs.type && value.crs.type === 'name' && value.crs.properties && value.crs.properties.name) {
var crs = value.crs.properties.name;
if (crs.indexOf('EPSG:') === 0)
geometry.srid = parseInt(crs.substring(5));
else if (crs.indexOf('urn:ogc:def:crs:EPSG::') === 0)
geometry.srid = parseInt(crs.substring(22));
else
throw new Error('Unsupported crs: ' + crs);
}
else if (!isSubGeometry) {
geometry.srid = 4326;
}
return geometry;
};
Geometry.prototype.toEwkt = function () {
return 'SRID=' + this.srid + ';' + this.toWkt();
};
Geometry.prototype.toEwkb = function () {
var ewkb = new BinaryWriter(this._getWkbSize() + 4);
var wkb = this.toWkb();
ewkb.writeInt8(1);
ewkb.writeUInt32LE((wkb.slice(1, 5).readUInt32LE(0) | 0x20000000) >>> 0, true);
ewkb.writeUInt32LE(this.srid);
ewkb.writeBuffer(wkb.slice(5));
return ewkb.buffer;
};
Geometry.prototype._getWktType = function (wktType, isEmpty) {
var wkt = wktType;
if (this.hasZ && this.hasM)
wkt += ' ZM ';
else if (this.hasZ)
wkt += ' Z ';
else if (this.hasM)
wkt += ' M ';
if (isEmpty && !this.hasZ && !this.hasM)
wkt += ' ';
if (isEmpty)
wkt += 'EMPTY';
return wkt;
};
Geometry.prototype._getWktCoordinate = function (point) {
var coordinates = point.x + ' ' + point.y;
if (this.hasZ)
coordinates += ' ' + point.z;
if (this.hasM)
coordinates += ' ' + point.m;
return coordinates;
};
Geometry.prototype._writeWkbType = function (wkb, geometryType, parentOptions) {
var dimensionType = 0;
if (typeof this.srid === 'undefined' && (!parentOptions || typeof parentOptions.srid === 'undefined')) {
if (this.hasZ && this.hasM)
dimensionType += 3000;
else if (this.hasZ)
dimensionType += 1000;
else if (this.hasM)
dimensionType += 2000;
}
else {
if (this.hasZ)
dimensionType |= 0x80000000;
if (this.hasM)
dimensionType |= 0x40000000;
}
wkb.writeUInt32LE((dimensionType + geometryType) >>> 0, true);
};
Geometry.getTwkbPrecision = function (xyPrecision, zPrecision, mPrecision) {
return {
xy: xyPrecision,
z: zPrecision,
m: mPrecision,
xyFactor: Math.pow(10, xyPrecision),
zFactor: Math.pow(10, zPrecision),
mFactor: Math.pow(10, mPrecision)
};
};
Geometry.prototype._writeTwkbHeader = function (twkb, geometryType, precision, isEmpty) {
var type = (ZigZag.encode(precision.xy) << 4) + geometryType;
var metadataHeader = (this.hasZ || this.hasM) << 3;
metadataHeader += isEmpty << 4;
twkb.writeUInt8(type);
twkb.writeUInt8(metadataHeader);
if (this.hasZ || this.hasM) {
var extendedPrecision = 0;
if (this.hasZ)
extendedPrecision |= 0x1;
if (this.hasM)
extendedPrecision |= 0x2;
twkb.writeUInt8(extendedPrecision);
}
};
Geometry.prototype.toGeoJSON = function (options) {
var geoJSON = {};
if (this.srid) {
if (options) {
if (options.shortCrs) {
geoJSON.crs = {
type: 'name',
properties: {
name: 'EPSG:' + this.srid
}
};
}
else if (options.longCrs) {
geoJSON.crs = {
type: 'name',
properties: {
name: 'urn:ogc:def:crs:EPSG::' + this.srid
}
};
}
}
}
return geoJSON;
};

View File

@@ -1,169 +1,169 @@
module.exports = GeometryCollection;
var util = require('util');
var Types = require('./types');
var Geometry = require('./geometry');
var BinaryWriter = require('./binarywriter');
function GeometryCollection(geometries, srid) {
Geometry.call(this);
this.geometries = geometries || [];
this.srid = srid;
if (this.geometries.length > 0) {
this.hasZ = this.geometries[0].hasZ;
this.hasM = this.geometries[0].hasM;
}
}
util.inherits(GeometryCollection, Geometry);
GeometryCollection.Z = function (geometries, srid) {
var geometryCollection = new GeometryCollection(geometries, srid);
geometryCollection.hasZ = true;
return geometryCollection;
};
GeometryCollection.M = function (geometries, srid) {
var geometryCollection = new GeometryCollection(geometries, srid);
geometryCollection.hasM = true;
return geometryCollection;
};
GeometryCollection.ZM = function (geometries, srid) {
var geometryCollection = new GeometryCollection(geometries, srid);
geometryCollection.hasZ = true;
geometryCollection.hasM = true;
return geometryCollection;
};
GeometryCollection._parseWkt = function (value, options) {
var geometryCollection = new GeometryCollection();
geometryCollection.srid = options.srid;
geometryCollection.hasZ = options.hasZ;
geometryCollection.hasM = options.hasM;
if (value.isMatch(['EMPTY']))
return geometryCollection;
value.expectGroupStart();
do {
geometryCollection.geometries.push(Geometry.parse(value));
} while (value.isMatch([',']));
value.expectGroupEnd();
return geometryCollection;
};
GeometryCollection._parseWkb = function (value, options) {
var geometryCollection = new GeometryCollection();
geometryCollection.srid = options.srid;
geometryCollection.hasZ = options.hasZ;
geometryCollection.hasM = options.hasM;
var geometryCount = value.readUInt32();
for (var i = 0; i < geometryCount; i++)
geometryCollection.geometries.push(Geometry.parse(value, options));
return geometryCollection;
};
GeometryCollection._parseTwkb = function (value, options) {
var geometryCollection = new GeometryCollection();
geometryCollection.hasZ = options.hasZ;
geometryCollection.hasM = options.hasM;
if (options.isEmpty)
return geometryCollection;
var geometryCount = value.readVarInt();
for (var i = 0; i < geometryCount; i++)
geometryCollection.geometries.push(Geometry.parseTwkb(value));
return geometryCollection;
};
GeometryCollection._parseGeoJSON = function (value) {
var geometryCollection = new GeometryCollection();
for (var i = 0; i < value.geometries.length; i++)
geometryCollection.geometries.push(Geometry._parseGeoJSON(value.geometries[i], true));
if (geometryCollection.geometries.length > 0)
geometryCollection.hasZ = geometryCollection.geometries[0].hasZ;
return geometryCollection;
};
GeometryCollection.prototype.toWkt = function () {
if (this.geometries.length === 0)
return this._getWktType(Types.wkt.GeometryCollection, true);
var wkt = this._getWktType(Types.wkt.GeometryCollection, false) + '(';
for (var i = 0; i < this.geometries.length; i++)
wkt += this.geometries[i].toWkt() + ',';
wkt = wkt.slice(0, -1);
wkt += ')';
return wkt;
};
GeometryCollection.prototype.toWkb = function () {
var wkb = new BinaryWriter(this._getWkbSize());
wkb.writeInt8(1);
this._writeWkbType(wkb, Types.wkb.GeometryCollection);
wkb.writeUInt32LE(this.geometries.length);
for (var i = 0; i < this.geometries.length; i++)
wkb.writeBuffer(this.geometries[i].toWkb({ srid: this.srid }));
return wkb.buffer;
};
GeometryCollection.prototype.toTwkb = function () {
var twkb = new BinaryWriter(0, true);
var precision = Geometry.getTwkbPrecision(5, 0, 0);
var isEmpty = this.geometries.length === 0;
this._writeTwkbHeader(twkb, Types.wkb.GeometryCollection, precision, isEmpty);
if (this.geometries.length > 0) {
twkb.writeVarInt(this.geometries.length);
for (var i = 0; i < this.geometries.length; i++)
twkb.writeBuffer(this.geometries[i].toTwkb());
}
return twkb.buffer;
};
GeometryCollection.prototype._getWkbSize = function () {
var size = 1 + 4 + 4;
for (var i = 0; i < this.geometries.length; i++)
size += this.geometries[i]._getWkbSize();
return size;
};
GeometryCollection.prototype.toGeoJSON = function (options) {
var geoJSON = Geometry.prototype.toGeoJSON.call(this, options);
geoJSON.type = Types.geoJSON.GeometryCollection;
geoJSON.geometries = [];
for (var i = 0; i < this.geometries.length; i++)
geoJSON.geometries.push(this.geometries[i].toGeoJSON());
return geoJSON;
};
module.exports = GeometryCollection;
var util = require('util');
var Types = require('./types');
var Geometry = require('./geometry');
var BinaryWriter = require('./binarywriter');
function GeometryCollection(geometries, srid) {
Geometry.call(this);
this.geometries = geometries || [];
this.srid = srid;
if (this.geometries.length > 0) {
this.hasZ = this.geometries[0].hasZ;
this.hasM = this.geometries[0].hasM;
}
}
util.inherits(GeometryCollection, Geometry);
GeometryCollection.Z = function (geometries, srid) {
var geometryCollection = new GeometryCollection(geometries, srid);
geometryCollection.hasZ = true;
return geometryCollection;
};
GeometryCollection.M = function (geometries, srid) {
var geometryCollection = new GeometryCollection(geometries, srid);
geometryCollection.hasM = true;
return geometryCollection;
};
GeometryCollection.ZM = function (geometries, srid) {
var geometryCollection = new GeometryCollection(geometries, srid);
geometryCollection.hasZ = true;
geometryCollection.hasM = true;
return geometryCollection;
};
GeometryCollection._parseWkt = function (value, options) {
var geometryCollection = new GeometryCollection();
geometryCollection.srid = options.srid;
geometryCollection.hasZ = options.hasZ;
geometryCollection.hasM = options.hasM;
if (value.isMatch(['EMPTY']))
return geometryCollection;
value.expectGroupStart();
do {
geometryCollection.geometries.push(Geometry.parse(value));
} while (value.isMatch([',']));
value.expectGroupEnd();
return geometryCollection;
};
GeometryCollection._parseWkb = function (value, options) {
var geometryCollection = new GeometryCollection();
geometryCollection.srid = options.srid;
geometryCollection.hasZ = options.hasZ;
geometryCollection.hasM = options.hasM;
var geometryCount = value.readUInt32();
for (var i = 0; i < geometryCount; i++)
geometryCollection.geometries.push(Geometry.parse(value, options));
return geometryCollection;
};
GeometryCollection._parseTwkb = function (value, options) {
var geometryCollection = new GeometryCollection();
geometryCollection.hasZ = options.hasZ;
geometryCollection.hasM = options.hasM;
if (options.isEmpty)
return geometryCollection;
var geometryCount = value.readVarInt();
for (var i = 0; i < geometryCount; i++)
geometryCollection.geometries.push(Geometry.parseTwkb(value));
return geometryCollection;
};
GeometryCollection._parseGeoJSON = function (value) {
var geometryCollection = new GeometryCollection();
for (var i = 0; i < value.geometries.length; i++)
geometryCollection.geometries.push(Geometry._parseGeoJSON(value.geometries[i], true));
if (geometryCollection.geometries.length > 0)
geometryCollection.hasZ = geometryCollection.geometries[0].hasZ;
return geometryCollection;
};
GeometryCollection.prototype.toWkt = function () {
if (this.geometries.length === 0)
return this._getWktType(Types.wkt.GeometryCollection, true);
var wkt = this._getWktType(Types.wkt.GeometryCollection, false) + '(';
for (var i = 0; i < this.geometries.length; i++)
wkt += this.geometries[i].toWkt() + ',';
wkt = wkt.slice(0, -1);
wkt += ')';
return wkt;
};
GeometryCollection.prototype.toWkb = function () {
var wkb = new BinaryWriter(this._getWkbSize());
wkb.writeInt8(1);
this._writeWkbType(wkb, Types.wkb.GeometryCollection);
wkb.writeUInt32LE(this.geometries.length);
for (var i = 0; i < this.geometries.length; i++)
wkb.writeBuffer(this.geometries[i].toWkb({ srid: this.srid }));
return wkb.buffer;
};
GeometryCollection.prototype.toTwkb = function () {
var twkb = new BinaryWriter(0, true);
var precision = Geometry.getTwkbPrecision(5, 0, 0);
var isEmpty = this.geometries.length === 0;
this._writeTwkbHeader(twkb, Types.wkb.GeometryCollection, precision, isEmpty);
if (this.geometries.length > 0) {
twkb.writeVarInt(this.geometries.length);
for (var i = 0; i < this.geometries.length; i++)
twkb.writeBuffer(this.geometries[i].toTwkb());
}
return twkb.buffer;
};
GeometryCollection.prototype._getWkbSize = function () {
var size = 1 + 4 + 4;
for (var i = 0; i < this.geometries.length; i++)
size += this.geometries[i]._getWkbSize();
return size;
};
GeometryCollection.prototype.toGeoJSON = function (options) {
var geoJSON = Geometry.prototype.toGeoJSON.call(this, options);
geoJSON.type = Types.geoJSON.GeometryCollection;
geoJSON.geometries = [];
for (var i = 0; i < this.geometries.length; i++)
geoJSON.geometries.push(this.geometries[i].toGeoJSON());
return geoJSON;
};

View File

@@ -1,178 +1,178 @@
module.exports = LineString;
var util = require('util');
var Geometry = require('./geometry');
var Types = require('./types');
var Point = require('./point');
var BinaryWriter = require('./binarywriter');
function LineString(points, srid) {
Geometry.call(this);
this.points = points || [];
this.srid = srid;
if (this.points.length > 0) {
this.hasZ = this.points[0].hasZ;
this.hasM = this.points[0].hasM;
}
}
util.inherits(LineString, Geometry);
LineString.Z = function (points, srid) {
var lineString = new LineString(points, srid);
lineString.hasZ = true;
return lineString;
};
LineString.M = function (points, srid) {
var lineString = new LineString(points, srid);
lineString.hasM = true;
return lineString;
};
LineString.ZM = function (points, srid) {
var lineString = new LineString(points, srid);
lineString.hasZ = true;
lineString.hasM = true;
return lineString;
};
LineString._parseWkt = function (value, options) {
var lineString = new LineString();
lineString.srid = options.srid;
lineString.hasZ = options.hasZ;
lineString.hasM = options.hasM;
if (value.isMatch(['EMPTY']))
return lineString;
value.expectGroupStart();
lineString.points.push.apply(lineString.points, value.matchCoordinates(options));
value.expectGroupEnd();
return lineString;
};
LineString._parseWkb = function (value, options) {
var lineString = new LineString();
lineString.srid = options.srid;
lineString.hasZ = options.hasZ;
lineString.hasM = options.hasM;
var pointCount = value.readUInt32();
for (var i = 0; i < pointCount; i++)
lineString.points.push(Point._readWkbPoint(value, options));
return lineString;
};
LineString._parseTwkb = function (value, options) {
var lineString = new LineString();
lineString.hasZ = options.hasZ;
lineString.hasM = options.hasM;
if (options.isEmpty)
return lineString;
var previousPoint = new Point(0, 0, options.hasZ ? 0 : undefined, options.hasM ? 0 : undefined);
var pointCount = value.readVarInt();
for (var i = 0; i < pointCount; i++)
lineString.points.push(Point._readTwkbPoint(value, options, previousPoint));
return lineString;
};
LineString._parseGeoJSON = function (value) {
var lineString = new LineString();
if (value.coordinates.length > 0)
lineString.hasZ = value.coordinates[0].length > 2;
for (var i = 0; i < value.coordinates.length; i++)
lineString.points.push(Point._readGeoJSONPoint(value.coordinates[i]));
return lineString;
};
LineString.prototype.toWkt = function () {
if (this.points.length === 0)
return this._getWktType(Types.wkt.LineString, true);
return this._getWktType(Types.wkt.LineString, false) + this._toInnerWkt();
};
LineString.prototype._toInnerWkt = function () {
var innerWkt = '(';
for (var i = 0; i < this.points.length; i++)
innerWkt += this._getWktCoordinate(this.points[i]) + ',';
innerWkt = innerWkt.slice(0, -1);
innerWkt += ')';
return innerWkt;
};
LineString.prototype.toWkb = function (parentOptions) {
var wkb = new BinaryWriter(this._getWkbSize());
wkb.writeInt8(1);
this._writeWkbType(wkb, Types.wkb.LineString, parentOptions);
wkb.writeUInt32LE(this.points.length);
for (var i = 0; i < this.points.length; i++)
this.points[i]._writeWkbPoint(wkb);
return wkb.buffer;
};
LineString.prototype.toTwkb = function () {
var twkb = new BinaryWriter(0, true);
var precision = Geometry.getTwkbPrecision(5, 0, 0);
var isEmpty = this.points.length === 0;
this._writeTwkbHeader(twkb, Types.wkb.LineString, precision, isEmpty);
if (this.points.length > 0) {
twkb.writeVarInt(this.points.length);
var previousPoint = new Point(0, 0, 0, 0);
for (var i = 0; i < this.points.length; i++)
this.points[i]._writeTwkbPoint(twkb, precision, previousPoint);
}
return twkb.buffer;
};
LineString.prototype._getWkbSize = function () {
var coordinateSize = 16;
if (this.hasZ)
coordinateSize += 8;
if (this.hasM)
coordinateSize += 8;
return 1 + 4 + 4 + (this.points.length * coordinateSize);
};
LineString.prototype.toGeoJSON = function (options) {
var geoJSON = Geometry.prototype.toGeoJSON.call(this, options);
geoJSON.type = Types.geoJSON.LineString;
geoJSON.coordinates = [];
for (var i = 0; i < this.points.length; i++) {
if (this.hasZ)
geoJSON.coordinates.push([this.points[i].x, this.points[i].y, this.points[i].z]);
else
geoJSON.coordinates.push([this.points[i].x, this.points[i].y]);
}
return geoJSON;
};
module.exports = LineString;
var util = require('util');
var Geometry = require('./geometry');
var Types = require('./types');
var Point = require('./point');
var BinaryWriter = require('./binarywriter');
function LineString(points, srid) {
Geometry.call(this);
this.points = points || [];
this.srid = srid;
if (this.points.length > 0) {
this.hasZ = this.points[0].hasZ;
this.hasM = this.points[0].hasM;
}
}
util.inherits(LineString, Geometry);
LineString.Z = function (points, srid) {
var lineString = new LineString(points, srid);
lineString.hasZ = true;
return lineString;
};
LineString.M = function (points, srid) {
var lineString = new LineString(points, srid);
lineString.hasM = true;
return lineString;
};
LineString.ZM = function (points, srid) {
var lineString = new LineString(points, srid);
lineString.hasZ = true;
lineString.hasM = true;
return lineString;
};
LineString._parseWkt = function (value, options) {
var lineString = new LineString();
lineString.srid = options.srid;
lineString.hasZ = options.hasZ;
lineString.hasM = options.hasM;
if (value.isMatch(['EMPTY']))
return lineString;
value.expectGroupStart();
lineString.points.push.apply(lineString.points, value.matchCoordinates(options));
value.expectGroupEnd();
return lineString;
};
LineString._parseWkb = function (value, options) {
var lineString = new LineString();
lineString.srid = options.srid;
lineString.hasZ = options.hasZ;
lineString.hasM = options.hasM;
var pointCount = value.readUInt32();
for (var i = 0; i < pointCount; i++)
lineString.points.push(Point._readWkbPoint(value, options));
return lineString;
};
LineString._parseTwkb = function (value, options) {
var lineString = new LineString();
lineString.hasZ = options.hasZ;
lineString.hasM = options.hasM;
if (options.isEmpty)
return lineString;
var previousPoint = new Point(0, 0, options.hasZ ? 0 : undefined, options.hasM ? 0 : undefined);
var pointCount = value.readVarInt();
for (var i = 0; i < pointCount; i++)
lineString.points.push(Point._readTwkbPoint(value, options, previousPoint));
return lineString;
};
LineString._parseGeoJSON = function (value) {
var lineString = new LineString();
if (value.coordinates.length > 0)
lineString.hasZ = value.coordinates[0].length > 2;
for (var i = 0; i < value.coordinates.length; i++)
lineString.points.push(Point._readGeoJSONPoint(value.coordinates[i]));
return lineString;
};
LineString.prototype.toWkt = function () {
if (this.points.length === 0)
return this._getWktType(Types.wkt.LineString, true);
return this._getWktType(Types.wkt.LineString, false) + this._toInnerWkt();
};
LineString.prototype._toInnerWkt = function () {
var innerWkt = '(';
for (var i = 0; i < this.points.length; i++)
innerWkt += this._getWktCoordinate(this.points[i]) + ',';
innerWkt = innerWkt.slice(0, -1);
innerWkt += ')';
return innerWkt;
};
LineString.prototype.toWkb = function (parentOptions) {
var wkb = new BinaryWriter(this._getWkbSize());
wkb.writeInt8(1);
this._writeWkbType(wkb, Types.wkb.LineString, parentOptions);
wkb.writeUInt32LE(this.points.length);
for (var i = 0; i < this.points.length; i++)
this.points[i]._writeWkbPoint(wkb);
return wkb.buffer;
};
LineString.prototype.toTwkb = function () {
var twkb = new BinaryWriter(0, true);
var precision = Geometry.getTwkbPrecision(5, 0, 0);
var isEmpty = this.points.length === 0;
this._writeTwkbHeader(twkb, Types.wkb.LineString, precision, isEmpty);
if (this.points.length > 0) {
twkb.writeVarInt(this.points.length);
var previousPoint = new Point(0, 0, 0, 0);
for (var i = 0; i < this.points.length; i++)
this.points[i]._writeTwkbPoint(twkb, precision, previousPoint);
}
return twkb.buffer;
};
LineString.prototype._getWkbSize = function () {
var coordinateSize = 16;
if (this.hasZ)
coordinateSize += 8;
if (this.hasM)
coordinateSize += 8;
return 1 + 4 + 4 + (this.points.length * coordinateSize);
};
LineString.prototype.toGeoJSON = function (options) {
var geoJSON = Geometry.prototype.toGeoJSON.call(this, options);
geoJSON.type = Types.geoJSON.LineString;
geoJSON.coordinates = [];
for (var i = 0; i < this.points.length; i++) {
if (this.hasZ)
geoJSON.coordinates.push([this.points[i].x, this.points[i].y, this.points[i].z]);
else
geoJSON.coordinates.push([this.points[i].x, this.points[i].y]);
}
return geoJSON;
};

Some files were not shown because too many files have changed in this diff Show More