Commit 8f58062a authored by Patrick's avatar Patrick
Browse files

neu

parent fe53c685
node_modules/
build/
src/
vcm/datasource-data/
vcm/doc/
vcm/examples/
vcm/fonts/
vcm/global/
vcm/i18n/
vcm/lib/
vcm/images/content/
vcm/images/editor/
vcm/images/overviewmap/
vcm/images/widgets/
vcm/img/drawing/
vcm/img/export/
vcm/img/flight/
vcm/img/height-profile/
vcm/img/measurement/
vcm/img/pdf-export/
vcm/img/planner/
\ No newline at end of file
#### Getting Started
Requirements: **NodeJS 6 LTS** and **npm 3** in your PATH.
1. Check the folder structure. An exported (compiled) **virtualcityMAP** must be in the _vcm_ path, relative to the root of your project
```
- .
|- build/
|- src/
|- test/
|- vcm/ <- needs to be copied
|- .babelrc
|- package.json
```
2. Install all the needed dependencies using `npm install`
3. To run the examples, execute `npm run examples`
#### Reading the _docs_
Once you have the development server running, you will find the documentation of the **vcm** API
at [http://localhost:8081/doc/index.html](http://localhost:8081/doc/index.html).
Further reading:
- [Vuejs](https://vuejs.org/)
- [vue-router](https://router.vuejs.org/en/)
- [vuex](https://vuex.vuejs.org/en/)
- [openlayers](https://openlayers.org/en/latest/apidoc/index.html)
- [Cesium](https://cesiumjs.org/Cesium/Build/Documentation/index.html)
### Writing your own plugin
Using the examples as a basis, you can start writing your own plugins. Make sure to register your plugin by calling `vcs.ui.registerPlugin(options)`.
To start writing your own plugin, simple use the `src/index.js` as an entry point for your own plugin.
To stop running the examples, and run you own plugin, start the dev server with `npm start`.
It is important to only write _a single plugin_ and only call _vcs.ui.registerPlugin_ **once**.
Otherwise the build process will not properly run through and the
configuration with the **virtualcityPUBLISHER** becomes impossible.
Once you are satisfied with your plugin, you can build it using `npm run build`.
This will create a zip-file containing your applications **bundled code** and **assets**.
To add your plugin to the **virtualcityPUBLISHER**, unzip the contents of this file into
the `root/public/plugins/` folder. The structur of the `public/plugins/` folder must look like this:
```
public/plugins
|- myPlugin/
|- assets/
|- myPlugin.js
|- config.json
|- mySecondPlugin/
|- assets/
|- mySecondPlugin.js
|- noAssetsPlugin/
|- noAssetsPlugin.js
|- config.json
```
Your plugin can now be added to **virtualcityMAP**s.
To ensure the usage of your plugin in a **virtualcityMAP** with a specific map version,
set the `vcm` property in the `package.json`s _engine_ property. The `package.json`
is shipped with your plugin, use it to define the current _version_ of your plugin,
the author and supported **virtualcityMAP** version.
To add your plugin to a deployed map, simply unzip the distribution into a folder
`plugins/`.
Add your plugin to a deployed map, by adding your plugin to the `config.json` under _ui.plugins_
and providing the name of your served plugin as
the key (this is especially useful if you wish to pass configurations to your plugin):
> This only works properly of you maintain the folder structure provided by the build script
> and use the `plugins/` directory on your server.
> If you use the virtualcityPUBLISHER to create your maps, this should not be an issue.
```json
...,
"ui": {
"plugins": {
"myPlugin": {
...
}
}
}
```
#### Adding static data to your plugin
You may wish to add your own icons, images or other forms of static content. For this, use the
`assets/` folder. You can then request your resource with `assets/yourResource`. The build script
will automatically change this URLs to `plugins/myPlugin/assets/yourResource` for ease of deployment
#### Adding configuration to your plugin
Some plugins might need configuring. You can add your configuration to the vcm's `config.json`
in the section _ui.plugins.myPlugin_ as shown above. To allow for a configuration of your
plugin by the **virtualcityPUBLISHER**, you can specify the configurable parameters of your
plugin in the `config.json` found in the root of your application. Add the keys
and their default values to this JSON.
```json
{
"myKey": "defaultValue",
"myNumeric": 123,
"myBoolean": true,
"myArray": [1, 2, 3]
}
```
#### Testing your plugin
Test are written for the `mocha` test framework, using `chai` for assertation and `sinon` for spies, stubs and mocks and `karma` as a test runner.
To run the tests, run `npm test`. In the `test/` directory you will find a small example _spec_.
var http = require("http");
var auth = require("http-auth");
var basic = auth.basic({
authRealm: "Private area",
authFile: __dirname + "/htpasswd",
authType: "basic"
});
var server = http.createServer(function(request, response) {
basic.apply(request, response, function(username) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello " + username);
response.end();
});
});
server.listen(80);
console.log("Server is listening");
\ No newline at end of file
var gulp = require('gulp');
var gutil = require('gulp-util');
var replace = require('gulp-replace');
var gulpif = require('gulp-if');
var rename = require('gulp-rename');
var zip = require('gulp-zip');
var del = require('del');
var vinylPaths = require('vinyl-paths');
var runSequence = require('run-sequence');
var program = require('commander');
var spawn = require('child_process').spawn;
var jeditor = require('gulp-json-editor');
var fs = require('fs');
program
.option('-p, --plugin <name>', 'the name to use for the plugin, overwrites the default')
.option('-l, --library <name>', 'to export the plugin as a library')
.parse(process.argv);
var pluginName = program.plugin;
gulp.task('clean', function() {
return del([
'dist/*'
]);
});
gulp.task('webpack-modern', function(cb) {
const child = spawn('node', ['node_modules/webpack/bin/webpack.js', '--config', 'build/webpack.prod.conf.js'], {
env: Object.assign({
VUE_CLI_MODERN_BUILD: true,
LIBRARY_NAME: program.library,
}, process.env),
});
child.stdout.on('data', (data) => {
gutil.log(data.toString());
});
child.stderr.on('data', (data) => {
gutil.log(data.toString());
});
child.on('close', (code) => {
if (code) {
throw new gutil.PluginError('webpack modern', code);
}
cb();
});
});
gulp.task('webpack-legacy', function(cb) {
const child = spawn('node', ['node_modules/webpack/bin/webpack.js', '--config', 'build/webpack.prod.conf.js'], {
env: Object.assign({
LIBRARY_NAME: program.library,
}, process.env),
});
child.stdout.on('data', (data) => {
gutil.log(data.toString());
});
child.stderr.on('data', (data) => {
gutil.log(data.toString());
});
child.on('close', (code) => {
if (code) {
throw new gutil.PluginError('webpack legacy', code);
}
cb();
});
});
gulp.task('uglify-modern', function(cb) { // TODO replace with terser-webpack-plugin when moving to webpack 4
const child = spawn('node', ['node_modules/terser/bin/uglifyjs', '--mangle', '--output', 'dist/plugin.es6.js', 'dist/plugin._es6.js']);
child.stdout.on('data', (data) => {
gutil.log(data.toString());
});
child.stderr.on('data', (data) => {
gutil.log(data.toString());
});
child.on('close', (code) => {
if (code) {
throw new gutil.PluginError('webpack modern', code);
}
fs.unlink('dist/plugin._es6.js', (err) => {
if (err) {
throw new guitl.PluginError('webpack modern', err);
}
cb();
});
});
});
gulp.task('replace', function() {
return gulp.src(['dist/*.js'])
.pipe(gulpif(!pluginName, replace(/registerPlugin\((.*)\)/, function(match) {
pluginName = match.match(/name:"(\w+)"/)[1];
return match;
})))
.pipe(replace(/\.?\/?(assets|img|fonts|media)\//g, function(match, folder) {
return `plugins/${pluginName}/`;
}))
.pipe(vinylPaths(del))
.pipe(rename(function(path) {
path.basename = /\.es6$/.test(path.basename) ? `${pluginName}.es6` : pluginName;
}))
.pipe(gulp.dest('dist/'));
});
gulp.task('add-esmodule', function() {
if (!fs.existsSync('config.json')) {
fs.writeFileSync('config.json', '{}');
}
return gulp.src('config.json')
.pipe(jeditor({
_esmodule: true,
}))
.pipe(gulp.dest('.'));
});
gulp.task('zip', function() {
return gulp.src(['dist/*.js', 'assets/**/*', 'config.json', 'package.json', 'img/**/*', 'README.md'], { base: process.cwd() })
.pipe(rename(function (path) {
var ext = path.dirname !== 'dist' && path.dirname !== '.' ? path.dirname : '';
path.dirname = pluginName + '/' + ext;
}))
.pipe(zip(pluginName + '.zip'))
.pipe(gulp.dest('dist'));
});
gulp.task('build', function(cb) {
runSequence(
'clean',
'webpack-modern',
'webpack-legacy',
'uglify-modern',
'replace',
'add-esmodule',
'zip',
cb
);
});
gulp.task('default', ['build']);
This diff is collapsed.
{
"name": "virtualcityMAP-plugin",
"version": "3.4.0",
"description": "Node server running the vcMAP, with an example plugin for developers",
"scripts": {
"build": "gulp",
"start": "node build/dev-server.js",
"examples": "node build/dev-server.js examples"
},
"author": "virtualcitysystems",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.5.4",
"@babel/runtime": "^7.5.4",
"@vue/babel-preset-app": "^3.9.2",
"babel-loader": "^8.0.6",
"babel-plugin-istanbul": "^3.1.2",
"commander": "^2.12.1",
"connect-history-api-fallback": "^1.3.0",
"css-loader": "^0.28.4",
"del": "^3.0.0",
"eventsource-polyfill": "^0.9.6",
"express": "^4.15.3",
"friendly-errors-webpack-plugin": "^1.6.1",
"function-bind": "^1.1.0",
"gulp": "^3.9.1",
"gulp-if": "^2.0.2",
"gulp-json-editor": "^2.5.2",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.6.1",
"gulp-zip": "^4.0.0",
"html-webpack-plugin": "^2.30.1",
"http-proxy-middleware": "^0.17.4",
"opn": "^5.1.0",
"run-sequence": "^2.2.0",
"script-ext-html-webpack-plugin": "^2.1.3",
"style-loader": "^0.18.2",
"terser": "^4.1.2",
"vinyl-paths": "^2.1.0",
"vue": "^2.4.2",
"vue-hot-reload-api": "^2.1.0",
"vue-html-loader": "^1.2.4",
"vue-loader": "^13.0.2",
"vue-template-compiler": "^2.5.6",
"webpack": "^3.4.1",
"webpack-dev-middleware": "^1.12.0",
"webpack-hot-middleware": "^2.18.2"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0",
"vcm": ">= 3.5.0"
},
"dependencies": {
"ajax-request": "^1.2.3",
"http-auth": "^4.1.2",
"jquery": "^3.4.1",
"npm": "^6.13.6",
"soap": "^0.30.0"
},
"babel": {
"presets": [
"@vue/app"
]
}
}
const http = require('http');
const fs = require('fs');
const express = require('express')
const app = express();
const bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
const request = require('ajax-request');
app.use(express.static('vcm'));
app.listen(process.env.PORT || 8081);
const http = require('http');
const fs = require('fs');
const express = require('express')
const app = express();
const bodyParser = require('body-parser')
const soap = require('soap');
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
const request = require('ajax-request');
app.use(express.static('vcm'));
app.listen(process.env.PORT || 8080);
console.log("on 8080");
var url = 'http://193.196.137.147:8990/simstadt/services/SimStadt2MonthlyenergyBalance?wsdl';
var args = {
gmlid: 'DEBW522AA0003113b', // an example of a building in Essen DENW22AL700004Lv
cityID: 1,// Essen 3 // Stockach 1
ui: {
attic: true,
atticHeating: true,
basement: true,
basementHeating: true,
buildingType: "EFH", // other options: "RH", "MFH", "GFH", "HH"
flatRoof: true,
id: 'DEBW522AA0003113b', // equal with glmid
latitude: 51.44679140365339, // an example of a building in Essen
longitude: 6.967781962878631, // an example of a building in Essen
refurbishment: "statuQuo", // other options: "medium", "advanced"
simulationName: "MonthlyEnergyBalance", // just use this value for Heat/Cooling Demand
storeyCount: 3,
timestep: 1, // dummy integer, not yet integrated but mandatory
usageProfile: "Single Family House", // // other options: "Multi Family House"
yearOfConstruction: 1946
}
};
app.post('/getSimS', function(req,res){
try {
const data = req.body;
// console.log("data ==============")
// console.log(data.id);
args.gmlid = data.id
// console.log(data[0]);
// console.log(data[1]);
// console.log("args ==============")
// console.log(args);
//asdf
const returnedTarget = Object.assign(args.ui,data);
// args.ui = data;
// args.gmlid = data.id;
// console.log("returned ==============")
// console.log(returnedTarget)
// console.log("args ==============")
// console.log(args);
soap.createClient(url, function(err, client) {
client.getMonthlyEnergyBalance(args, function(err, result) {
if (err) throw err;
console.log(result);
// const obj = JSON.parse(result);
// console.log(obj)
res.json(result);
return result;
});
});
}
catch (err) {
console.log('.../getSimS failed!\n' + err);
}
});
...@@ -9,6 +9,9 @@ sa ...@@ -9,6 +9,9 @@ sa
fd fd
asd asd
<<<<<<< HEAD
fd
=======
f f
fslga;lgka fslga;lgka
g g
...@@ -18,3 +21,4 @@ sdg;lsdg;fdl;sg ...@@ -18,3 +21,4 @@ sdg;lsdg;fdl;sg
fsdlk fsdlk
>>>>>>> master
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment