Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Unike
/
UnikeInspection-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9430dc5a
authored
Jun 16, 2025
by
Augusto Fonte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
import sites kmz
parent
08db2e37
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
prisma/import-sites-from-kmz.ts
+20
-1
src/main.ts
+3
-3
No files found.
prisma/import-sites-from-kmz.ts
View file @
9430dc5a
import
fs
from
'fs'
;
import
AdmZip
from
'adm-zip'
;
import
*
as
AdmZip
from
'adm-zip'
;
import
{
XMLParser
}
from
'fast-xml-parser'
;
import
{
PrismaClient
}
from
'@prisma/client'
;
...
...
@@ -19,13 +19,30 @@ async function importKmzToSites(kmzPath: string) {
// 3. Extract Placemarks (handle both array and single object)
const
placemarks
=
(()
=>
{
const
doc
=
kml
.
kml
.
Document
;
// Check if placemarks are directly in Document
if
(
Array
.
isArray
(
doc
.
Placemark
))
return
doc
.
Placemark
;
if
(
doc
.
Placemark
)
return
[
doc
.
Placemark
];
// Check if placemarks are in a Folder
if
(
doc
.
Folder
&&
doc
.
Folder
.
Placemark
)
{
if
(
Array
.
isArray
(
doc
.
Folder
.
Placemark
))
return
doc
.
Folder
.
Placemark
;
return
[
doc
.
Folder
.
Placemark
];
}
return
[];
})();
console
.
log
(
`Found
${
placemarks
.
length
}
placemarks`
);
for
(
const
placemark
of
placemarks
)
{
const
name
=
placemark
.
name
||
''
;
if
(
!
placemark
.
Point
||
!
placemark
.
Point
.
coordinates
)
{
console
.
log
(
'Skipping placemark without Point/coordinates:'
,
name
);
continue
;
}
const
[
longitude
,
latitude
]
=
placemark
.
Point
.
coordinates
.
split
(
','
)
.
map
(
Number
);
...
...
@@ -49,6 +66,8 @@ async function importKmzToSites(kmzPath: string) {
}
catch
(
err
)
{
console
.
error
(
`Failed to import site
${
siteCode
}
:`
,
err
.
message
);
}
}
else
{
console
.
log
(
`Skipping invalid site:
${
siteCode
}
(missing data)`
);
}
}
console
.
log
(
'Import complete!'
);
...
...
src/main.ts
View file @
9430dc5a
...
...
@@ -32,8 +32,8 @@ async function bootstrap() {
// Swagger configuration
const
config
=
new
DocumentBuilder
()
.
setTitle
(
'
Cellnex
API'
)
.
setDescription
(
'The
Cellnex API for managing sites and candidate
s'
)
.
setTitle
(
'
Setling
API'
)
.
setDescription
(
'The
Setling API for managing sites and Inspection
s'
)
.
setVersion
(
'1.0'
)
.
addTag
(
'auth'
,
'Authentication endpoints'
)
.
addTag
(
'users'
,
'User management endpoints'
)
...
...
@@ -64,7 +64,7 @@ async function bootstrap() {
SwaggerModule
.
setup
(
'docs'
,
app
,
document
,
swaggerOptions
);
const
port
=
process
.
env
.
PORT
??
300
1
;
const
port
=
process
.
env
.
PORT
??
300
4
;
await
app
.
listen
(
port
);
console
.
log
(
`Application is running on: http://localhost:
${
port
}
`
);
console
.
log
(
...
...
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