Commit ac03bb55 authored by Henrik Grythe's avatar Henrik Grythe
Browse files

Various bugfixes and added gnu GPL licence flag

parent baf26d18
%--------------------------------------------------------------------------
% This file is part of NERVE
%
% NERVE is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation version 3.
%
% NERVE is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NERVE. If not, see <https://www.gnu.org/licenses/>.
%--------------------------------------------------------------------------
function Emission_Factor_Model_group_HBEFA()
%--------------------------------------------------------------------------
......
%--------------------------------------------------------------------------
% This file is part of NERVE
%
% NERVE is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation version 3.
%
% NERVE is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NERVE. If not, see <https://www.gnu.org/licenses/>.
%--------------------------------------------------------------------------
function Emission_Factor_Process_HBEFA_Matrix_Raw()
%--------------------------------------------------------------------------
% Script for reading and processing HBEFA .csv file of subsegments.
......
%--------------------------------------------------------------------------
% This file is part of NERVE
%
% NERVE is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation version 3.
%
% NERVE is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NERVE. If not, see <https://www.gnu.org/licenses/>.
%--------------------------------------------------------------------------
function Emission_Factor_Test_HBEFA_to_MODEL_conversion(com,ConVfile)
global EFA EF_AVG comps roads
fprintf('\tin Emission_Factor_Test_HBEFA_to_MODEL_conversion\n')
......@@ -89,4 +104,4 @@ fprintf('MODEL : %i / %i / %i \n',round(min(Traff.NumVehEF_MODEL)),round(mean(Tr
Traff = Traff(Traff.NumVehEF_MODEL>0|Traff.NumVehEF_HBEFA>0,:);
writetable(Traff,ConVfile,'Sheet',sprintf('%s',char(comps(com))))
end
\ No newline at end of file
end
%--------------------------------------------------------------------------
% This file is part of NERVE
%
% NERVE is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation version 3.
%
% NERVE is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NERVE. If not, see <https://www.gnu.org/licenses/>.
%--------------------------------------------------------------------------
function [Sn] = Emissions_Calculations(Calc_Links,Vehicle_dist)
%--------------------------------------------------------------------------
%
......
%--------------------------------------------------------------------------
% This file is part of NERVE
%
% NERVE is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation version 3.
%
% NERVE is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NERVE. If not, see <https://www.gnu.org/licenses/>.
%--------------------------------------------------------------------------
function [Sn] = Emissions_Calculations_HBEFA(Calc_Links)
global Tyear comps tfold Vehicle_source
......
%--------------------------------------------------------------------------
% This file is part of NERVE
%
% NERVE is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation version 3.
%
% NERVE is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NERVE. If not, see <https://www.gnu.org/licenses/>.
%--------------------------------------------------------------------------
function [Sn] = Emissions_Calculations_SSB(Calc_Links,Vehicle_dist)
%--------------------------------------------------------------------------
%
......@@ -24,6 +39,10 @@ file = sprintf('%s%s',tfold,'roads');
fprintf('Warning,using roads file not produced by NERVE model\n%s\n',file)
load(file)
L = extractfield(Calc_Links,sprintf('L_ADT%04i',Tyear)); % Traffic Volume (# day-1)
H = extractfield(Calc_Links,sprintf('H_ADT%04i',Tyear)); % Traffic Volume (# day-1)
B = extractfield(Calc_Links,sprintf('B_ADT%04i',Tyear)); % Traffic Volume (# day-1)
......@@ -94,6 +113,8 @@ nEM_Tot = zeros(size(aEM_L));
% set which compound (com)
for com = 1:length(comps)
Zroads = 0;
% load the emission factor
EFfile = sprintf('%sEFA_matrix41_MODEL_%s.mat',tfold,char(comps(com)));
......
%--------------------------------------------------------------------------
% This file is part of NERVE
%
% NERVE is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation version 3.
%
% NERVE is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NERVE. If not, see <https://www.gnu.org/licenses/>.
%--------------------------------------------------------------------------
function PreProcess_Emission_Factors_HBEFA()
%--------------------------------------------------------------------------
......
%--------------------------------------------------------------------------
% This file is part of NERVE
%
% NERVE is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation version 3.
%
% NERVE is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NERVE. If not, see <https://www.gnu.org/licenses/>.
%--------------------------------------------------------------------------
function [RLinks] = PreProcess_Roads_Input_Traffic()
%--------------------------------------------------------------------------
% Module to read in an original Road Network and traffic file.
......@@ -31,25 +46,20 @@ function [RLinks] = PreProcess_Roads_Input_Traffic()
% Kjeller NILU
%--------------------------------------------------------------------------
global tfold use_temporary_files tfiles
global traffile Komm_shape Listfields
global traffile Komm_shape Listfields Inputfields
fprintf('in PreProcess_Input_Traffic.\n')
% compare the list of field names to a list of requred fields
required_fields = [{'Geometry'},{'X'},{'Y'},{'KOLL_ADT'},{'LETTE_BILE' },{'GODS_ADT'},{'SUM_ADT'}];
% list of fields needed to do (if needed) matching on municipality grids:
location_fields = [{'KOMM'},{'MIDPOINT_X'},{'MIDPOINT_Y'},{'DISTANCE'}];
% List of input fields used
Inputfields = [{'Geometry'},{'X'},{'Y'},{'KOLL_ADT'},{'LETTE_BILE' },...
{'GODS_ADT'},{'SUM_ADT'},{'FM_TIME'},{'KO_MORGEN'},{'KO_ETTERM'},...
{'FM_SPEED'},{'SHAPE_LENG'},{'VK'},{'STIGNING_P'},{'SPEED'},{'HP_ID'},{'LANES'}];
% list of fields erquired for advanced calculations:
advanced_fields = [{'FM_TIME'},{'KO_MORGEN'},{'KO_ETTERM'},{'FM_SPEED'},{'SHAPE_LENG'},{'VK'},{'STIGNING_P'},{'SPEED'}];
% List of output fields a finished file has:
Listfields = [{'Geometry'},{'X'},{'Y'},{'BoundingBox'},{'DISTANCE'},{'KOMMS'},{'KOMME'},{'KOMM'},{'SPEED'},{'SLOPE'},...
{'URBAN'},{'RUSH_DELAY'},{'HBEFA_EQIV'},{'WIDTH'},{'CAPACITY'},{'N_LANES'},{'L_ADT'},{'H_ADT'},{'B_ADT'},{'IDO'}];
% list of fields generated by the model
fields_made = [{'URBAN'},{'RUSH_DELAY'},{'RUSH_SPEED'},{'SLOPE'},{'HBEFA_NUM'},{'HBEFA_EQIV'}];
% List of fields a finished file has:
Listfields = [{'Geometry'},{'X'},{'Y'},{'BoundingBox'},{'DISTANCE'},{'KOMM'},{'SPEED'},{'SLOPE'},...
{'URBAN'},{'RUSH_DELAY'},{'HBEFA_EQIV'},{'WIDTH'},{'CAPACITY'},{'N_LANES'},{'L_ADT'},{'H_ADT'},{'B_ADT'}];
if use_temporary_files
try
......@@ -90,97 +100,31 @@ else
end
fprintf('\n')
end
% Test if required fields are there:
for i=1:length(required_fields)
if isfield(RLinks,required_fields(i)) || use_temporary_files
else
required_fields(i)
error('Missing required field (possibly others)')
end
end
% Test if required fields are there:
for i=1:length(Listfields)
if isfield(RLinks,Listfields(i))
else
fprintf('Output field not defined yet: %s \n',char(Listfields(i)))
end
end
%--------------------------------------------------------------------------
miss_location = 0;
for i=1:length(location_fields)
if isfield(RLinks,location_fields(i))
else
fprintf('%s\n',char(location_fields(i)))
miss_location = 1;
end
end
if miss_location
RLinks = Roads_Add_Municipality(RLinks,Komm_shape);
else
fprintf('Already have necessary fields Location fields \n')
end
RLinks = Roads_clean_Input(RLinks);
%--------------------------------------------------------------------------
RLinks = Roads_Remove_NoTrafficRoads(RLinks);
%--------------------------------------------------------------------------
RLinks = Roads_Calc_DISTANCE(RLinks);
%--------------------------------------------------------------------------
RLinks = Roads_Add_Municipality(RLinks);
%--------------------------------------------------------------------------
RLinks = Roads_Find_StartMuncipalityFraction(RLinks);
%--------------------------------------------------------------------------
RLinks = Roads_Fix_Roadfields(RLinks);
RLinks = Roads_Recalc_DISTANCE(RLinks);
%--------------------------------------------------------------------------
if isfield(RLinks,'KAPTID_06_') && ~isfield(RLinks,'KOTID_MORGEN')
RLinks = Roads_Congestion_Parameters(RLinks);
end
miss_advanced = 0;
for i=1:length(advanced_fields)
if isfield(RLinks,advanced_fields(i))
else
miss_advanced = 1;
fprintf('Missing field to do Advanced calculations: %s \n',char(advanced_fields(i)))
fprintf('Maybe field %s is misnamed?\n',char(advanced_fields(i)))
warning('or proceed with simplistic calculation?\n')
end
end
RLinks = Roads_Congestion_Parameters(RLinks);
%--------------------------------------------------------------------------
% ADD fields (if missing)
% URBAN
if ~isfield(RLinks,'URBAN')
RLinks = Roads_Add_Urban(RLinks);
end
RLinks = Roads_Add_Urban(RLinks);
save('RLinks.mat','RLinks')
%--------------------------------------------------------------------------
% ADD fields (if missing)
% HBEFA
if ~isfield(RLinks,'HBEFA_NUM') || ~isfield(RLinks,'HBEFA_EQIV')
RLinks = Roads_Add_HBEFA_Parameters(RLinks);
end
RLinks = Roads_Add_HBEFA_Parameters(RLinks);
%--------------------------------------------------------------------------
% ADD fields (if missing)
% Advanced
if ~isfield(RLinks,'RUSH_DELAY') || ~isfield(RLinks,'RUSH_SPEED')|| ~isfield(RLinks,'SLOPE')
RLinks = Roads_Add_Advanced_Properties(RLinks);
end
RLinks = Roads_Congestion_Parameters(RLinks);
%--------------------------------------------------------------------------
% ADD fields (if missing)
if ~isfield(RLinks,'WIDTH') && isfield(RLinks,'DEKKEBREDD')|| isfield(RLinks,'LANES')
RLinks = Roads_Add_Width(RLinks);
end
% Scale Traffic from road year to traffic year:
RLinks = Roads_Scale_Traffic_to_Year(RLinks);
%--------------------------------------------------------------------------
if use_temporary_files
Save_shape(RLinks,tfiles.RL)
end
end
function [Sn] = Roads_Add_Advanced_Properties(RLinks)
% Convert Precentage into HBEAF interpretable 0,2,4,6 pct slopes
st = min(abs(round(50*extractfield(RLinks,'STIGNING_P'))*2),6);
fprintf('* in Add_Road_Advanced_Properties *\n')
% Calculate rush hour traffic speed and delay
di = extractfield(RLinks,'DISTANCE');
kt = extractfield(RLinks,'FM_TIME');
km = extractfield(RLinks,'KO_MORGEN');
ke = extractfield(RLinks,'KO_ETTERM');
ks = extractfield(RLinks,'FM_SPEED');
% The time traffic that is delayed is calculated by the mean of the
% morning and evening congestion
RUSH_DELAY = round(100*(kt+mean([ke;km]))./kt-100);
RUSH_DELAY(isnan(RUSH_DELAY)) = 0;
RUSH_SPEED = round(di./((kt.*(1+RUSH_DELAY/100)/60)));
RUSH_SPEED(isnan(RUSH_SPEED)) = 0;
RUSH_SPEED(RUSH_SPEED>kt) = kt(RUSH_SPEED>kt);
T = struct2table(RLinks);
T.RUSH_DELAY = RUSH_DELAY';
T.RUSH_SPEED = RUSH_SPEED';
T.SLOPE = st';
Sn = table2struct(T);
fprintf('Setfields\n -- RUSH_DELAY\n -- RUSH_SPEED\n -- SLOPE ...on all links \n')
end
%--------------------------------------------------------------------------
% This file is part of NERVE
%
% NERVE is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation version 3.
%
% NERVE is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NERVE. If not, see <https://www.gnu.org/licenses/>.
%--------------------------------------------------------------------------
function [Sn] = Roads_Add_HBEFA_Parameters(S)
%--------------------------------------------------------------------------
% Function to add the HBEFA road properties needed to assign emission
......
function [Sn] = Roads_Add_Municipality(RLinks,Komm_shape)
%-------------------------------------------------------------------------
% Miljodirektoratet Traffic emission model NERVE:
%
% FUNCTION :: HEDGE_Add_ROAD_Municipality ::
%
%--------------------------------------------------------------------------
% This file is part of NERVE
%
% NERVE is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation version 3.
%
% NERVE is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NERVE. If not, see <https://www.gnu.org/licenses/>.
%--------------------------------------------------------------------------
function [Sn] = Roads_Add_Municipality(RLinks)
% This function looks for and checks the national traffic file. It makes
% sure that it has the required fields and adds (some) fields if they are
% deducable from the input-traffic. As there is a lot of uneccesary data
......@@ -15,48 +25,68 @@ function [Sn] = Roads_Add_Municipality(RLinks,Komm_shape)
% may not be same in future extractions, and a change will have to be made
% in the script.
%
% -INPUT : this function reads the road link shapes per municipality to the
% temporary folder (tpath).
% -OUTPUT : this function adds properties to the road link shapes per
% municipality in the temporary folder (tpath).
%
%-------------------------------------------------------------------------
% 20.09.2018 -Henrik Grythe
% Kjeller NILU
%-------------------------------------------------------------------------
fprintf('* call Add_ROAD_Municipality *\n')
global Komm_shape
fprintf('\tin Roads_Add_Municipality *\n')
fprintf('Adding kommune field based on geo file: \n%s\n',Komm_shape)
Ks = shaperead(Komm_shape);
prj = read_projection(Komm_shape);
% Adds a Roads Midpoint based on the starting point and ending point of
% Road
if ~isfield(RLinks,'MIDPOINT_X') || ~isfield(RLinks,'MIDPOINT_Y')
for i=1:length(RLinks)
x=RLinks(i).X;
y=RLinks(i).Y;
for i = 1:length(RLinks)
x = RLinks(i).X;
y = RLinks(i).Y;
MIDPOINT_X(i)=(x(1)+x(end-1))/2;
MIDPOINT_Y(i)=(y(1)+y(end-1))/2;
end
else
MIDPOINT_X = extractfield(RLinks,'MIDPOINT_X');
MIDPOINT_Y = extractfield(RLinks,'MIDPOINT_Y');
MIDPOINT_X = extractfield(RLinks,'MIDPOINT_X');
MIDPOINT_Y = extractfield(RLinks,'MIDPOINT_Y');
end
teller = 0;
for i=1:length(Ks)
in = inpolygon(MIDPOINT_X,MIDPOINT_Y,Ks(i).X,Ks(i).Y);
KOMM(in) = extractfield(Ks(i),'KOMMUNENUM');
fprintf('%03i Kommune %04i_%s has %i roads \n',i,extractfield(Ks(i),'KOMMUNENUM'),char(extractfield(Ks(i),'NAVN')),sum(in))
has(in)=1; clear in
fprintf('Placed %i/%i = %4.1f%% \n',sum(has),length(RLinks), 100*sum(has)/length(RLinks))
for i = 1:length(RLinks)
x = RLinks(i).X;
y = RLinks(i).Y;
ix = ~isnan(x);
iy = ~isnan(x);
START_X(i) = x(ix(1));
START_Y(i) = y(iy(1));
END_X(i) = x(ix(1));
END_Y(i) = y(iy(1));
end
KOMMS = nan(size(START_X));
KOMME = nan(size(START_X));
KOMM = nan(size(START_X));
for i = 1:length(Ks)
% FIND STARTING MUNICIPALITY
inS = inpolygon(START_X,START_Y,Ks(i).X,Ks(i).Y);
% FIND ENDING MUNICIPALITY
inE = inpolygon(END_X,END_Y,Ks(i).X,Ks(i).Y);
% FIND MIDPOINT MUNICIPALITY
inM = inpolygon(MIDPOINT_X,MIDPOINT_Y,Ks(i).X,Ks(i).Y);
KOMMS(inS) = extractfield(Ks(i),'KOMMUNENUM');
KOMME(inE) = extractfield(Ks(i),'KOMMUNENUM');
KOMM(inM) = extractfield(Ks(i),'KOMMUNENUM');
hasS(inS) = 1;
hasE(inE) = 1;
hasM(inM) = 1;
fprintf('%03i Kommune %04i_%-24s has %5i roadS \t',i,extractfield(Ks(i),'KOMMUNENUM'),char(extractfield(Ks(i),'NAVN')),sum(inS))
fprintf('(%i/%i = %4.1f%%) \n',sum(hasS),length(RLinks), 100*sum(hasS)/length(RLinks))
clear inS inE inM
end
fprintf('Have: %7i of %7i Roadlinks "KOMM START", missing: %i \n',sum(hasS),length(RLinks),length(RLinks)-sum(hasS))
fprintf('Have: %7i of %7i Roadlinks "KOMM END ", missing: %i \n',sum(hasE),length(RLinks),length(RLinks)-sum(hasE))
fprintf('Have: %7i of %7i Roadlinks "KOMM MIDP.", missing: %i \n',sum(hasM),length(RLinks),length(RLinks)-sum(hasM))
fprintf('Have: %i of %i Roadlinks "KOMM", missing: %i \n',sum(has),length(RLinks),length(RLinks)-sum(has))
% teller = 0;
% try midpoint start point and end point of road, which commune it
% will be decided.
missing=find(has==0);
missing = find(hasM==0);
if ~isempty(missing)
% If midpoint doesnt work, do it on the starting point
for i=1:length(missing)
......@@ -66,13 +96,14 @@ if ~isempty(missing)
in = inpolygon(x(1),y(1),Ks(j).X,Ks(j).Y);
if ~isempty(in)
KOMM(missing(i)) = extractfield(Ks(j),'KOMMUNENUM');
has(missing(i)) = 1;
hasM(missing(i)) = 1;
end
end
end
end
fprintf('Have: %i of %i Roadlinks "KOMM", missing: %i \n',sum(has),length(RLinks),length(RLinks)-sum(has))
missing=find(has==0);
fprintf('Have: %7i of %7i Roadlinks "KOMM", missing: %i \n',sum(hasM),length(RLinks),length(RLinks)-sum(hasM))
missing = find(hasM==0);
if ~isempty(missing)
% If startpoint doesnt work, do it on the ending point
for i=1:length(missing)
......@@ -81,40 +112,24 @@ if ~isempty(missing)
for j=1:length(Ks)
in = inpolygon(x(end-1),y(end-1),Ks(j).X,Ks(j).Y);
if ~isempty(in)
KOMM(missing(i)) = extractfield(Ks(j),'KOMM');
has(missing(i)) = 1;
KOMM(missing(i)) = extractfield(Ks(j),'KOMMUNENUM');
hasM(missing(i)) = 1;
end
end
end
end
fprintf('Have: %i of %i Roadlinks "KOMM", missing: %i \n',sum(has),length(RLinks),length(RLinks)-sum(has))
if ~isfield(RLinks,'DISTANCE')
for i=1:length(RLinks)
x=RLinks(i).X;
y=RLinks(i).Y;
DISTANCE(i)=sqrt((x(1)+x(end-1))^2+(y(1)+y(end-1))^2);
end
end
fprintf('Have: %7i of %7i Roadlinks "KOMM", missing: %i \n',sum(hasM),length(RLinks),length(RLinks)-sum(hasM))
% Convert briefly to a table variable to make some calculations
% that take more time in structures.
T=struct2table(RLinks);
T.KOMM=KOMM';
T.MIDPOINT_X=MIDPOINT_X';
T.MIDPOINT_Y=MIDPOINT_Y';
fprintf('Setfields\n -- KOMM\n -- MIDPOINT_X\n -- MIDPOINT_Y ...on all links \n')
if ~isfield(RLinks,'DISTANCE')
for i=1:length(RLinks)
x=RLinks(i).X;
y=RLinks(i).Y;
DISTANCE(i)=sqrt((x(1)+x(end-1))^2+(y(1)+y(end-1))^2);
end
T.DISTANCE=DISTANCE';
fprintf('Setfields\n -- DISTANCE ...on all links \n')
end
T.KOMM = KOMM';
T.KOMMS = KOMMS';
T.KOMME = KOMME';
T.MIDPOINT_X = MIDPOINT_X';
T.MIDPOINT_Y = MIDPOINT_Y';
fprintf('Setfields\n -- KOMM Kommune (Mid)\n -- KOMMS Start Kommune \n')
fprintf(' -- KOMME Endekommune \n -- MIDPOINT_X\n -- MIDPOINT_Y ...on all links \n')
Sn = table2struct(T);
end
%--------------------------------------------------------------------------
% This file is part of NERVE
%
% NERVE is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation version 3.
%
% NERVE is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NERVE. If not, see <https://www.gnu.org/licenses/>.
%--------------------------------------------------------------------------
function [Sn] = Roads_Add_Urban(RLinks)
%-------------------------------------------------------------------------
% Miljodirektoratet Traffic emission model NERVE:
......@@ -43,7 +58,7 @@ for i=1:length(Tshape)
my=nanmean(Tshape(i).Y);
dst =sqrt((MIDPOINT_X-mx).^2 + (MIDPOINT_Y-my).^2)*1e-3;
idx = find(dst<max_dist);
fprintf('Checking %6i roads in tettsted %04i %12s',length(idx),i,char(Tshape(i).Tettstedsn))
fprintf('Checking %6i roads in tettsted %04i_%-18s',length(idx),i,char(Tshape(i).Tettstedsn))
IN = inpolygon(MIDPOINT_X(idx), MIDPOINT_Y(idx),Tshape(i).X,Tshape(i).Y);
I = cat(2,I,idx(IN));
fprintf('... Found %6i roads \n',length(idx(IN)))
......
%--------------------------------------------------------------------------
% This file is part of NERVE
%
% NERVE is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation version 3.
%
% NERVE is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NERVE. If not, see <https://www.gnu.org/licenses/>.
%--------------------------------------------------------------------------
function [Sn] = Roads_Calc_DISTANCE(RLinks)
fprintf('in Roads_Calc_DISTANCE.\n')