Skip to content

Commit

Permalink
Merge branch 'd3:main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
vzan2012 committed Aug 14, 2022
2 parents 952e792 + 48a5559 commit 7692e6a
Show file tree
Hide file tree
Showing 144 changed files with 2,560 additions and 2,092 deletions.
6 changes: 1 addition & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
"sourceType": "module",
"ecmaVersion": 8
},
"env": {
"es6": true
},
"rules": {
"no-cond-assign": 0,
"no-constant-condition": 0,
"no-floating-decimal": 2
"no-constant-condition": 0
}
}
18 changes: 18 additions & 0 deletions .github/eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "eslint-compact",
"pattern": [
{
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5,
"code": 6
}
]
}
]
}
30 changes: 30 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn --frozen-lockfile
- run: |
echo ::add-matcher::.github/eslint.json
yarn run eslint src test --format=compact
- run: yarn test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.sublime-workspace
.DS_Store
dist/
test/output/
node_modules
npm-debug.log
43 changes: 13 additions & 30 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,39 +1,22 @@
Copyright 2013-2016 Mike Bostock
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Copyright 2013-2021 Mike Bostock

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.

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.

MIT License for https://github.com/scijs/integrate-adaptive-simpson

The MIT License (MIT)

Copyright (c) 2015 Ricky Reusser
Copyright 2015 Ricky Reusser

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -51,4 +34,4 @@ 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 SOFTWARE.
534 changes: 273 additions & 261 deletions README.md

Large diffs are not rendered by default.

65 changes: 36 additions & 29 deletions bin/geo2svg → bin/geo2svg.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/usr/bin/env node

var os = require("os"),
commander = require("commander"),
d3 = Object.assign({}, require("d3-geo"), require("../")),
read = require("./read"),
write = require("./write");
import {EOL} from "os";
import {program} from "commander";
import {geoPath} from "d3-geo";
import {readFileSync} from "fs";
import {dirname, resolve} from "path";
import {fileURLToPath} from "url";
import {geoQuantize} from "../src/index.js";
import read from "./read.js";
import write from "./write.js";

commander
.version(require("../package.json").version)
const version = JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "../package.json"))).version;

const options = program
.version(version)
.usage("[options] [file]")
.description("Convert GeoJSON to SVG.")
.option("-o, --out <file>", "output file name; defaults to “-” for stdout", "-")
Expand All @@ -18,31 +24,36 @@ commander
.option("--fill <value>", "default fill", "none")
.option("--stroke <value>", "default stroke", "black")
.option("-r, --radius <value>", "default point radius", 4.5)
.parse(process.argv);
.parse(process.argv)
.opts();

if (commander.args.length === 0) commander.args[0] = "-";
else if (commander.args.length !== 1) {
if (program.args.length === 0) program.args[0] = "-";
else if (program.args.length !== 1) {
console.error();
console.error(" error: multiple input files");
console.error();
process.exit(1);
}

var reader = read(commander.args[0], commander.newlineDelimited, transform).then(end).catch(abort),
writer = write(commander.out),
path = d3.geoPath().pointRadius(function(d) { var p = d.properties, v; return p && (v = p["point-radius"] || p.pointRadius) != null ? v : commander.radius; }),
render = commander.precision == null ? path : function(d) { return path(d3.geoQuantize(d, commander.precision)); };
var reader = read(program.args[0], options.newlineDelimited, transform).then(end),
writer = write(options.out),
path = geoPath().pointRadius(function(d) { var p = d.properties, v; return p && (v = p["point-radius"] || p.pointRadius) != null ? v : options.radius; }),
render = options.precision == null ? path : function(d) { return path(geoQuantize(d, options.precision)); };

reader.catch(error => {
console.error(error.stack);
});

writer.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + os.EOL
+ "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">" + os.EOL
+ "<!-- Generated by geo2svg " + require("../package.json").version + ". https://d3js.org/d3-geo-projection/ -->" + os.EOL
writer.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + EOL
+ "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">" + EOL
+ "<!-- Generated by geo2svg " + version + ". https://d3js.org/d3-geo-projection/ -->" + EOL
+ "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\""
+ " width=\"" + +commander.width + "\""
+ " height=\"" + +commander.height + "\""
+ " viewBox=\"0 0 " + +commander.width + " " + +commander.height + "\""
+ (commander.fill != "black" ? " fill=\"" + attr(commander.fill) + "\"" : "")
+ (commander.stroke != "none" ? " stroke=\"" + attr(commander.stroke) + "\"" : "")
+ ">" + os.EOL);
+ " width=\"" + +options.width + "\""
+ " height=\"" + +options.height + "\""
+ " viewBox=\"0 0 " + +options.width + " " + +options.height + "\""
+ (options.fill != "black" ? " fill=\"" + attr(options.fill) + "\"" : "")
+ (options.stroke != "none" ? " stroke=\"" + attr(options.stroke) + "\"" : "")
+ ">" + EOL);

function transform(d) {
var p = d.properties, v;
Expand All @@ -63,15 +74,11 @@ function transform(d) {
+ (v = render(d), v ? " d=\"" + v + "\"" : "")
+ ">"
+ ((v = p && p["title"]) != null ? "<title>" + text(v + "") + "</title>" : "")
+ "</path>" + os.EOL);
+ "</path>" + EOL);
}

function end() {
return writer.write("</svg>" + os.EOL);
}

function abort(error) {
console.error(error.stack);
return writer.write("</svg>" + EOL);
}

function text(string) {
Expand Down
44 changes: 26 additions & 18 deletions bin/geograticule → bin/geograticule.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#!/usr/bin/env node

var commander = require("commander"),
graticule = require("d3-geo").geoGraticule(),
write = require("./write");
import {program} from "commander";
import {geoGraticule} from "d3-geo";
import {readFileSync} from "fs";
import {dirname, resolve} from "path";
import {fileURLToPath} from "url";
import write from "./write.js";

commander
.version(require("../package.json").version)
const version = JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "../package.json"))).version;

const graticule = geoGraticule();

const options = program
.version(version)
.usage("[options]")
.description("Generate a GeoJSON graticule.")
.option("-o, --out <file>", "output file name; defaults to “-” for stdout", "-")
Expand All @@ -16,29 +23,30 @@ commander
.option("--step-minor <value>", "the minor step; defaults to " + graticule.stepMinor(), parseStep)
.option("--step-major <value>", "the major step; defaults to " + graticule.stepMajor(), parseStep)
.option("--precision <value>", "the precision; defaults to " + graticule.precision(), graticule.precision)
.parse(process.argv);
.parse(process.argv)
.opts();

if (commander.args.length !== 0) {
if (program.args.length !== 0) {
console.error();
console.error(" error: unexpected arguments");
console.error();
process.exit(1);
}

if (commander.extent != null) {
if (commander.extentMinor == null) commander.extentMinor = commander.extent;
if (commander.extentMajor == null) commander.extentMajor = commander.extent;
if (options.extent != null) {
if (options.extentMinor == null) options.extentMinor = options.extent;
if (options.extentMajor == null) options.extentMajor = options.extent;
}
if (commander.step != null) {
if (commander.stepMinor == null) commander.stepMinor = commander.step;
if (commander.stepMajor == null) commander.stepMajor = commander.step;
if (options.step != null) {
if (options.stepMinor == null) options.stepMinor = options.step;
if (options.stepMajor == null) options.stepMajor = options.step;
}
if (commander.extentMinor != null) graticule.extentMinor(commander.extentMinor);
if (commander.extentMajor != null) graticule.extentMajor(commander.extentMajor);
if (commander.stepMinor != null) graticule.stepMinor(commander.stepMinor);
if (commander.stepMajor != null) graticule.stepMajor(commander.stepMajor);
if (options.extentMinor != null) graticule.extentMinor(options.extentMinor);
if (options.extentMajor != null) graticule.extentMajor(options.extentMajor);
if (options.stepMinor != null) graticule.stepMinor(options.stepMinor);
if (options.stepMajor != null) graticule.stepMajor(options.stepMajor);

var writer = write(commander.out);
var writer = write(options.out);
writer.write(JSON.stringify(graticule()) + "\n");
writer.end().catch(abort);

Expand Down
53 changes: 0 additions & 53 deletions bin/geoproject

This file was deleted.

Loading

0 comments on commit 7692e6a

Please sign in to comment.