Замкнул хрень!!

This commit is contained in:
zakhy 2025-03-24 17:19:27 +07:00
parent 8ade6935c7
commit 3788385e8a

View File

@ -822,7 +822,7 @@
if (feature) {
features.push(feature);
}
}
});
return features;
@ -885,106 +885,106 @@
}
function dxfToGeoJSON(dxf) {
console.log(dxf);
const normalizedEntities = normalizeCoordinates(dxf.entities, dxf.header);
let features = [];
console.log(dxf);
const normalizedEntities = normalizeCoordinates(dxf.entities, dxf.header);
let features = [];
normalizedEntities.forEach(entity => {
DXFLayersList.push(entity.layer);
normalizedEntities.forEach(entity => {
DXFLayersList.push(entity.layer);
if (entity.type === 'INSERT') {
// Обрабатываем блоки
const blockFeatures = processBlockInsert(entity, dxf);
console.log(blockFeatures);
if (blockFeatures && blockFeatures.length > 0) {
features.push(...blockFeatures);
}
if (entity.type === 'INSERT') {
// Обрабатываем блоки
const blockFeatures = processBlockInsert(entity, dxf);
console.log(blockFeatures);
if (blockFeatures && blockFeatures.length > 0) {
features.push(...blockFeatures);
}
} else {
// Обрабатываем обычные сущности
let feature = null;
if (entity.type === 'LINE') {
feature = createFeature('LineString',
entity.normalizedCoords,
{
style: {
"stroke-color": getColorByColorTable(entity.colorIndex),
"stroke-width": 1,
},
"layer": entity.layer
});
} else if (entity.type === 'LWPOLYLINE' || entity.type === 'POLYLINE') {
const coords = entity.normalizedCoords;
// Для замкнутых полилиний добавляем первую точку в конец
if (entity.shape && coords.length > 0) {
coords.push(coords[0]); // Замыкаем полигон
}
console.log(entity)
feature = createFeature(
entity.shape ? 'Polygon' : 'LineString',
entity.shape ? [coords] : coords,
{
style: {
...getStyleFromDXFEntity(entity, dxf.tables.lineType?.lineTypes),
},
"layer": entity.layer
}
);
} else if (entity.type === 'TEXT' || entity.type === 'MTEXT') {
feature = createFeature('Point',
entity.normalizedCoords[0],
{
style: {
...getStyleFromDXFEntity(entity)
},
"layer": entity.layer
});
} else if (entity.type === 'CIRCLE') {
feature = createFeature('Point',
entity.normalizedCoords[0],
{
style: {
...getStyleFromDXFEntity(entity, dxf.tables.lineType?.lineTypes)
},
"layer": entity.layer
});
} else if (entity.type === 'ARC') {
feature = createFeature('LineString',
entity.normalizedCoords,
{
style: {
...getStyleFromDXFEntity(entity, dxf.tables.lineType?.lineTypes)
},
"layer": entity.layer
});
} else if (entity.type === 'POINT') {
feature = createFeature('Point',
entity.normalizedCoords[0],
{
style: {
...getStyleFromDXFEntity(entity, dxf.tables.lineType?.lineTypes)
},
"layer": entity.layer
});
} else if (entity.type === 'SPLINE') {
feature = createFeature('LineString',
entity.normalizedCoords,
{
style: {
...getStyleFromDXFEntity(entity, dxf.tables.lineType?.lineTypes)
},
"layer": entity.layer
});
}
if (feature) {
features.push(feature);
}
}
});
return {type: 'FeatureCollection', features: features};
}
else {
// Обрабатываем обычные сущности
let feature = null;
if (entity.type === 'LINE') {
feature = createFeature('LineString',
entity.normalizedCoords,
{
style: {
"stroke-color": getColorByColorTable(entity.colorIndex),
"stroke-width": 1,
},
"layer": entity.layer
});
}
else if (entity.type === 'LWPOLYLINE' || entity.type === 'POLYLINE') {
const coords = entity.normalizedCoords;
feature = createFeature(entity.closed ? 'Polygon' : 'LineString',
entity.closed ? [coords] : coords,
{
style: {
...getStyleFromDXFEntity(entity, dxf.tables.lineType?.lineTypes)
},
"layer": entity.layer
});
}
else if (entity.type === 'TEXT' || entity.type === 'MTEXT') {
feature = createFeature('Point',
entity.normalizedCoords[0],
{
style: {
...getStyleFromDXFEntity(entity)
},
"layer": entity.layer
});
}
else if (entity.type === 'CIRCLE') {
feature = createFeature('Point',
entity.normalizedCoords[0],
{
style: {
...getStyleFromDXFEntity(entity, dxf.tables.lineType?.lineTypes)
},
"layer": entity.layer
});
}
else if (entity.type === 'ARC') {
feature = createFeature('LineString',
entity.normalizedCoords,
{
style: {
...getStyleFromDXFEntity(entity, dxf.tables.lineType?.lineTypes)
},
"layer": entity.layer
});
}
else if (entity.type === 'POINT') {
feature = createFeature('Point',
entity.normalizedCoords[0],
{
style: {
...getStyleFromDXFEntity(entity, dxf.tables.lineType?.lineTypes)
},
"layer": entity.layer
});
}
else if (entity.type === 'SPLINE') {
feature = createFeature('LineString',
entity.normalizedCoords,
{
style: {
...getStyleFromDXFEntity(entity, dxf.tables.lineType?.lineTypes)
},
"layer": entity.layer
});
}
if (feature) {
features.push(feature);
}
}
});
return {type: 'FeatureCollection', features: features};
}
function createFeature(type, coordinates, properties) {
i++