Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
ng-smart3d
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张启明
ng-smart3d
Commits
40afa7a5
Commit
40afa7a5
authored
Dec 31, 2019
by
张启明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: 添加通视分析和天际线
parent
c3f6fb51
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
212 additions
and
29 deletions
+212
-29
app.component.css
src/app/app.component.css
+6
-0
app.component.html
src/app/app.component.html
+6
-2
app.component.ts
src/app/app.component.ts
+2
-1
app.module.ts
src/app/app.module.ts
+8
-2
index.ts
src/app/components/index.ts
+2
-0
index.ts
src/app/components/layer-manager/index.ts
+1
-0
layer-manager.component.css
src/app/components/layer-manager/layer-manager.component.css
+0
-0
layer-manager.component.html
...app/components/layer-manager/layer-manager.component.html
+1
-0
layer-manager.component.spec.ts
.../components/layer-manager/layer-manager.component.spec.ts
+25
-0
layer-manager.component.ts
src/app/components/layer-manager/layer-manager.component.ts
+15
-0
measure-hander.component.ts
...pp/components/measure-handler/measure-hander.component.ts
+1
-4
measure-handler.component.css
.../components/measure-handler/measure-handler.component.css
+0
-6
measure-handler.component.html
...components/measure-handler/measure-handler.component.html
+4
-7
sight-line.component.html
src/app/components/sight-line/sight-line.component.html
+4
-1
sight-line.component.ts
src/app/components/sight-line/sight-line.component.ts
+18
-1
index.ts
src/app/components/skyline/index.ts
+1
-0
skyline.component.css
src/app/components/skyline/skyline.component.css
+0
-0
skyline.component.html
src/app/components/skyline/skyline.component.html
+4
-0
skyline.component.spec.ts
src/app/components/skyline/skyline.component.spec.ts
+25
-0
skyline.component.ts
src/app/components/skyline/skyline.component.ts
+41
-0
index.ts
src/app/services/index.ts
+1
-0
index.ts
src/app/services/layer-manager/index.ts
+1
-0
layer-manager.service.spec.ts
src/app/services/layer-manager/layer-manager.service.spec.ts
+12
-0
layer-manager.service.ts
src/app/services/layer-manager/layer-manager.service.ts
+16
-0
viewer.service.ts
src/app/services/viewer/viewer.service.ts
+18
-5
No files found.
src/app/app.component.css
View file @
40afa7a5
#container
{
position
:
relative
;
}
.widgets
{
position
:
absolute
;
display
:
flex
;
flex-direction
:
column
;
}
src/app/app.component.html
View file @
40afa7a5
<h1>
Ng smart3d
</h1>
<div
id=
"container"
>
<app-measure-handler></app-measure-handler>
<div
class=
"widgets"
>
<app-measure-handler></app-measure-handler>
<app-sight-line></app-sight-line>
<app-skyline></app-skyline>
<app-layer-manager></app-layer-manager>
</div>
</div>
src/app/app.component.ts
View file @
40afa7a5
...
...
@@ -18,7 +18,8 @@ export class AppComponent implements OnInit {
this
.
viewer
=
this
.
viewerService
.
initViewer
(
'container'
,
{
sceneMode
:
smart3d
.
SceneMode
.
SCENE3D
,
scene3DOnly
:
true
,
terrainProvider
:
smart3d
.
TerrainManager
.
createWorldTerrain
()
terrainProvider
:
smart3d
.
TerrainManager
.
createWorldTerrain
(),
helper
:
false
,
});
}
}
src/app/app.module.ts
View file @
40afa7a5
...
...
@@ -2,14 +2,20 @@ import { BrowserModule } from '@angular/platform-browser';
import
{
NgModule
}
from
'@angular/core'
;
import
{
AppComponent
}
from
'./app.component'
;
import
{
MeasureHandlerComponent
}
from
'./components'
;
import
{
SightLineComponent
}
from
'./components/sight-line/sight-line.component'
;
import
{
MeasureHandlerComponent
,
SightLineComponent
,
LayerManagerComponent
,
SkylineComponent
,
}
from
'./components'
;
@
NgModule
({
declarations
:
[
AppComponent
,
MeasureHandlerComponent
,
SightLineComponent
,
LayerManagerComponent
,
SkylineComponent
,
],
imports
:
[
BrowserModule
...
...
src/app/components/index.ts
View file @
40afa7a5
export
*
from
'./measure-handler'
;
export
*
from
'./sight-line'
;
export
*
from
'./layer-manager'
;
export
*
from
'./skyline'
;
src/app/components/layer-manager/index.ts
0 → 100644
View file @
40afa7a5
export
*
from
'./layer-manager.component'
;
src/app/components/layer-manager/layer-manager.component.css
0 → 100644
View file @
40afa7a5
src/app/components/layer-manager/layer-manager.component.html
0 → 100644
View file @
40afa7a5
<p>
layer-manager works!
</p>
src/app/components/layer-manager/layer-manager.component.spec.ts
0 → 100644
View file @
40afa7a5
import
{
async
,
ComponentFixture
,
TestBed
}
from
'@angular/core/testing'
;
import
{
LayerManagerComponent
}
from
'./layer-manager.component'
;
describe
(
'LayerManagerComponent'
,
()
=>
{
let
component
:
LayerManagerComponent
;
let
fixture
:
ComponentFixture
<
LayerManagerComponent
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
LayerManagerComponent
]
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
LayerManagerComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'should create'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
src/app/components/layer-manager/layer-manager.component.ts
0 → 100644
View file @
40afa7a5
import
{
Component
,
OnInit
}
from
'@angular/core'
;
@
Component
({
selector
:
'app-layer-manager'
,
templateUrl
:
'./layer-manager.component.html'
,
styleUrls
:
[
'./layer-manager.component.css'
]
})
export
class
LayerManagerComponent
implements
OnInit
{
constructor
()
{
}
ngOnInit
()
{
}
}
src/app/components/measure-handler/measure-hander.component.ts
View file @
40afa7a5
...
...
@@ -8,10 +8,7 @@ import { ViewerService } from 'src/app/services';
})
export
class
MeasureHandlerComponent
implements
OnInit
{
public
handleMeasure
:
(
measureMode
:
number
,
options
?:
{
isGround
:
boolean
;
showLabel
:
boolean
;
})
=>
any
;
public
handleMeasure
:
(
measureMode
:
number
,
isGround
:
boolean
,
showLabel
:
boolean
)
=>
any
;
public
measureMode
=
smart3d
.
MeasureMode
;
constructor
(
...
...
src/app/components/measure-handler/measure-handler.component.css
View file @
40afa7a5
.buttons
{
position
:
absolute
;
top
:
20px
;
left
:
20px
;
}
\ No newline at end of file
src/app/components/measure-handler/measure-handler.component.html
View file @
40afa7a5
<div
class=
"buttons"
>
<div>
<button
(
click
)="
handleMeasure
(
measureMode
.
Distance
)"
>
不贴地距离测量
</button>
<button
(
click
)="
handleMeasure
(
measureMode
.
Distance
,
{
isGround:
true
})"
>
贴地距离测量
</button>
<button
(
click
)="
handleMeasure
(
measureMode
.
Distance
,
true
)"
>
贴地距离测量
</button>
<button
(
click
)="
handleMeasure
(
measureMode
.
Area
)"
>
不贴地面积测量
</button>
<button
(
click
)="
handleMeasure
(
measureMode
.
Area
,
{
isGround:
true
})"
>
贴地面积测量
</button>
<button
(
click
)="
handleMeasure
(
measureMode
.
Area
,
true
)"
>
贴地面积测量
</button>
<button
(
click
)="
handleMeasure
(
measureMode
.
Angle
)"
>
角度测量
</button>
<button
(
click
)="
handleMeasure
(
measureMode
.
DVH
)"
>
空间距离,水平距离,垂直距离模式测量
</button>
</div>
\ No newline at end of file
src/app/components/sight-line/sight-line.component.html
View file @
40afa7a5
<p>
sight-line works!
</p>
<div>
<button
(
click
)="
handleSightLine
()"
>
通视分析
</button>
</div>
\ No newline at end of file
src/app/components/sight-line/sight-line.component.ts
View file @
40afa7a5
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
ViewerService
}
from
'src/app/services'
;
@
Component
({
selector
:
'app-sight-line'
,
...
...
@@ -7,9 +8,25 @@ import { Component, OnInit } from '@angular/core';
})
export
class
SightLineComponent
implements
OnInit
{
constructor
()
{
}
constructor
(
private
viewerService
:
ViewerService
,
)
{
}
ngOnInit
()
{
}
handleSightLine
()
{
const
viewer
=
this
.
viewerService
.
viewer
;
const
drawHandler
=
new
smart3d
.
DrawHandler
(
viewer
,
smart3d
.
DrawMode
.
Line
);
const
positions
=
[];
drawHandler
.
anchorEvent
.
addEventListener
(
position
=>
{
if
(
positions
.
push
(
position
)
>=
2
)
{
const
sightLine
=
new
smart3d
.
SightLine
(
viewer
.
scene
,
positions
[
0
],
positions
[
1
]);
drawHandler
.
clear
();
drawHandler
.
destroy
();
sightLine
.
build
();
}
});
drawHandler
.
activate
();
}
}
src/app/components/skyline/index.ts
0 → 100644
View file @
40afa7a5
export
*
from
'./skyline.component'
;
src/app/components/skyline/skyline.component.css
0 → 100644
View file @
40afa7a5
src/app/components/skyline/skyline.component.html
0 → 100644
View file @
40afa7a5
<div>
<button
(
click
)="
toggleSkyline
()"
>
{{ showSkyline ? '关闭' : '开启' }}天际线
</button>
</div>
\ No newline at end of file
src/app/components/skyline/skyline.component.spec.ts
0 → 100644
View file @
40afa7a5
import
{
async
,
ComponentFixture
,
TestBed
}
from
'@angular/core/testing'
;
import
{
SkylineComponent
}
from
'./skyline.component'
;
describe
(
'SkylineComponent'
,
()
=>
{
let
component
:
SkylineComponent
;
let
fixture
:
ComponentFixture
<
SkylineComponent
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
SkylineComponent
]
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
SkylineComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'should create'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
src/app/components/skyline/skyline.component.ts
0 → 100644
View file @
40afa7a5
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
ViewerService
}
from
'src/app/services'
;
@
Component
({
selector
:
'app-skyline'
,
templateUrl
:
'./skyline.component.html'
,
styleUrls
:
[
'./skyline.component.css'
]
})
export
class
SkylineComponent
implements
OnInit
{
public
showSkyline
=
false
;
private
skyline
;
private
oldDepthTestAgainstTerrainValue
:
boolean
;
constructor
(
private
viewerService
:
ViewerService
,
)
{
}
ngOnInit
()
{
}
toggleSkyline
()
{
this
.
showSkyline
=
!
this
.
showSkyline
;
const
viewer
=
this
.
viewerService
.
viewer
;
if
(
this
.
showSkyline
)
{
// 需要开启 depthTestAgainstTerrain,天际线才会围住地形,否则会围住 globe
this
.
oldDepthTestAgainstTerrainValue
=
viewer
.
scene
.
globe
.
depthTestAgainstTerrain
;
viewer
.
scene
.
globe
.
depthTestAgainstTerrain
=
true
;
this
.
skyline
=
new
smart3d
.
SkyLine
(
viewer
,
{
// width: 10,
// lineColor: Cesium.Color.GREEN,
// strokeDis: 1e9,
});
}
else
{
this
.
skyline
.
destroy
();
viewer
.
scene
.
globe
.
depthTestAgainstTerrain
=
this
.
oldDepthTestAgainstTerrainValue
;
}
}
}
src/app/services/index.ts
View file @
40afa7a5
export
*
from
'./viewer'
;
export
*
from
'./layer-manager'
;
src/app/services/layer-manager/index.ts
0 → 100644
View file @
40afa7a5
export
*
from
'./layer-manager.service'
;
src/app/services/layer-manager/layer-manager.service.spec.ts
0 → 100644
View file @
40afa7a5
import
{
TestBed
}
from
'@angular/core/testing'
;
import
{
LayerManagerService
}
from
'./layer-manager.service'
;
describe
(
'LayerManagerService'
,
()
=>
{
beforeEach
(()
=>
TestBed
.
configureTestingModule
({}));
it
(
'should be created'
,
()
=>
{
const
service
:
LayerManagerService
=
TestBed
.
get
(
LayerManagerService
);
expect
(
service
).
toBeTruthy
();
});
});
src/app/services/layer-manager/layer-manager.service.ts
0 → 100644
View file @
40afa7a5
import
{
Injectable
}
from
'@angular/core'
;
import
{
ViewerService
}
from
'../viewer'
;
@
Injectable
({
providedIn
:
'root'
})
export
class
LayerManagerService
{
private
layerManager
;
constructor
(
private
viewerService
:
ViewerService
)
{
console
.
log
(
this
.
viewerService
.
viewer
);
}
}
src/app/services/viewer/viewer.service.ts
View file @
40afa7a5
...
...
@@ -7,6 +7,7 @@ export class ViewerService {
// tslint:disable-next-line: variable-name
private
_viewer
;
private
layerManager
;
private
measureHandler
;
constructor
()
{
...
...
@@ -21,14 +22,23 @@ export class ViewerService {
initViewer
(
container
:
string
|
Element
,
options
?:
object
):
object
{
if
(
!
this
.
_viewer
)
{
this
.
_viewer
=
new
smart3d
.
Viewer
(
container
,
options
||
{});
this
.
layerManager
=
new
smart3d
.
LayerManager
(
this
.
_viewer
);
// tslint:disable-next-line: no-string-literal
window
[
'viewer'
]
=
this
.
_viewer
;
}
return
this
.
_viewer
;
}
handleMeasure
(
measureMode
:
number
,
options
?:
{
isGround
:
boolean
;
showLabel
:
boolean
;
})
{
addLayer
(
layer
)
{
this
.
layerManager
.
addLayer
(
layer
);
}
flyToLayer
(
layer
)
{
this
.
layerManager
.
flyTo
(
layer
);
}
handleMeasure
(
measureMode
:
number
,
isGround
?:
boolean
,
showLabel
?:
boolean
)
{
if
(
measureMode
!==
smart3d
.
MeasureMode
.
Distance
&&
measureMode
!==
smart3d
.
MeasureMode
.
Angle
&&
...
...
@@ -38,8 +48,11 @@ export class ViewerService {
throw
new
Cesium
.
DeveloperError
(
'measure mode must be one of smart3d.MeasureMode'
);
}
isGround
=
undefined
===
isGround
?
false
:
isGround
;
showLabel
=
undefined
===
showLabel
?
true
:
showLabel
;
if
(
this
.
_viewer
)
{
this
.
measureHandler
=
new
smart3d
.
MeasureHandler
(
this
.
viewer
,
measureMode
,
options
&&
options
);
this
.
measureHandler
=
new
smart3d
.
MeasureHandler
(
this
.
viewer
,
measureMode
,
isGround
,
showLabel
);
this
.
measureHandler
.
activate
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment